Sha256: 86ae370cbca42a5eee867e2d98116cde4dcdd2fe200e2607b4888ab793146f83

Contents?: true

Size: 652 Bytes

Versions: 10

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

require_relative "./common"
require "globalid"

module Fixtury
  module LocatorBackend
    class GlobalId

      include ::Fixtury::LocatorBackend::Common

      MATCHER = %r{^gid://}.freeze

      def recognizable_key?(locator_value)
        locator_value.is_a?(String) && MATCHER.match?(locator_value)
      end

      def recognizable_value?(stored_value)
        stored_value.respond_to?(:to_global_id)
      end

      def load_reference(locator_value)
        ::GlobalID::Locator.locate locator_value
      end

      def dump_value(stored_value)
        stored_value.to_global_id.to_s
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fixtury-2.0.2 lib/fixtury/locator_backend/global_id.rb
fixtury-2.0.0 lib/fixtury/locator_backend/global_id.rb
fixtury-1.0.1 lib/fixtury/locator_backend/global_id.rb
fixtury-1.0.0 lib/fixtury/locator_backend/global_id.rb
fixtury-1.0.0.beta7 lib/fixtury/locator_backend/global_id.rb
fixtury-1.0.0.beta6 lib/fixtury/locator_backend/global_id.rb
fixtury-1.0.0.beta5 lib/fixtury/locator_backend/global_id.rb
fixtury-1.0.0.beta4 lib/fixtury/locator_backend/global_id.rb
fixtury-1.0.0.beta3 lib/fixtury/locator_backend/global_id.rb
fixtury-1.0.0.beta2 lib/fixtury/locator_backend/global_id.rb