From 532e4cda05efc5a4af565377612247f24f8f9828 Mon Sep 17 00:00:00 2001 From: Rainer Borene Date: Wed, 29 Jun 2022 22:36:13 -0300 Subject: [PATCH] feat(fixture_set): implement non signed global_id helper method --- lib/global_id/fixture_set.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/global_id/fixture_set.rb b/lib/global_id/fixture_set.rb index 44f01af..68fb401 100644 --- a/lib/global_id/fixture_set.rb +++ b/lib/global_id/fixture_set.rb @@ -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