Skip to content

Commit

Permalink
feat(fixture_set): implement non signed global_id helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
rainerborene committed Jun 30, 2022
1 parent 42832cd commit 532e4cd
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 532e4cd

Please sign in to comment.