Skip to content

Commit

Permalink
Merge pull request #144 from rainerborene/feature/fixture_set
Browse files Browse the repository at this point in the history
feat(fixture_set): implement non signed global_id helper method
  • Loading branch information
rafaelfranca committed Jan 3, 2023
2 parents b670d36 + 532e4cd commit add93e1
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/global_id/fixture_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

class GlobalID
module FixtureSet
def signed_global_id(fixture_set_name, label, column_type: :integer, **options)
identifier = identify(label, column_type)
model_name = default_fixture_model_name(fixture_set_name)
uri = URI::GID.build([GlobalID.app, model_name, identifier, {}])
def global_id(fixture_set_name, label, column_type: :integer, **options)
create_global_id(fixture_set_name, label, column_type: column_type, klass: GlobalID, **options)
end

SignedGlobalID.new(uri, **options)
def signed_global_id(fixture_set_name, label, column_type: :integer, **options)
create_global_id(fixture_set_name, label, column_type: column_type, klass: SignedGlobalID, **options)
end

private
def create_global_id(fixture_set_name, label, klass:, column_type: :integer, **options)
identifier = identify(label, column_type)
model_name = default_fixture_model_name(fixture_set_name)
uri = URI::GID.build([GlobalID.app, model_name, identifier, {}])
klass.new(uri, **options)
end
end
end

0 comments on commit add93e1

Please sign in to comment.