diff --git a/lib/global_id/fixture_set.rb b/lib/global_id/fixture_set.rb new file mode 100644 index 0000000..44f01af --- /dev/null +++ b/lib/global_id/fixture_set.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +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, {}]) + + SignedGlobalID.new(uri, **options) + end + end +end diff --git a/lib/global_id/railtie.rb b/lib/global_id/railtie.rb index 8db99a0..1860950 100644 --- a/lib/global_id/railtie.rb +++ b/lib/global_id/railtie.rb @@ -37,6 +37,11 @@ class Railtie < Rails::Railtie # :nodoc: require 'global_id/identification' send :include, GlobalID::Identification end + + ActiveSupport.on_load(:active_record_fixture_set) do + require 'global_id/fixture_set' + send :extend, GlobalID::FixtureSet + end end end end