Sha256: 22082e718418357e4d67ac8c10706439e0b411b98496ac26d003e1a86cf8e9c9

Contents?: true

Size: 1.18 KB

Versions: 23

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require_relative "type/class_methods"

module ConvenientService
  module Common
    module Plugins
      module HasCallbacks
        module Entities
          class Type
            include Support::Castable
            include Support::Delegate

            extend ClassMethods

            attr_reader :value

            delegate :hash, to: :value

            def initialize(value:)
              @value = value
            end

            def ==(other)
              return unless other.instance_of?(self.class)

              return false if value != other.value

              true
            end

            ##
            # NOTE: Used by `contain_exactly`. Check its specs.
            #
            # NOTE: This method is intented to be used only for hash keys comparison,
            # when you know for sure that `other` is always an `Entities::Type` instance.
            #
            # IMPORTANT: Do NOT use `eql?` without a strong reason, prefer `==`.
            #
            def eql?(other)
              return unless other.instance_of?(self.class)

              hash == other.hash
            end
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.19.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.18.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.17.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.16.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.15.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.14.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.13.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.12.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.11.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.10.1 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.10.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.9.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.8.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.7.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.6.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.5.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.4.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.3.1 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb
convenient_service-0.3.0 lib/convenient_service/common/plugins/has_callbacks/entities/type.rb