File: fixture_set.rb

package info (click to toggle)
ruby-globalid 1.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: ruby: 1,675; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 804 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

class GlobalID
  module FixtureSet
    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

    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