Sha256: f8cc5a7353e18576c038d5c818a8b4ee9c7c657a5f1bc54669124f7594cbed0e

Contents?: true

Size: 658 Bytes

Versions: 4

Compression:

Stored size: 658 Bytes

Contents

# frozen_string_literal: true

module Checkpoint
  class Resource
    # Specialized Resource type to represent all entities of a particular type.
    class AllOfType < Resource
      attr_reader :type
      # Create a wildcard Resource for a given type
      def initialize(type)
        @type = type
      end

      # This is always the special ALL resource ID
      def id
        Resource::ALL
      end

      # Compares with another Resource
      #
      # @return [Boolean] true if `other` is a Resource and its #type matches.
      def eql?(other)
        other.is_a?(Resource) && type == other.type
      end

      alias == eql?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
checkpoint-1.1.3 lib/checkpoint/resource/all_of_type.rb
checkpoint-1.1.2 lib/checkpoint/resource/all_of_type.rb
checkpoint-1.1.1 lib/checkpoint/resource/all_of_type.rb
checkpoint-1.1.0 lib/checkpoint/resource/all_of_type.rb