Class: ConvenientService::Common::Plugins::CanHaveCallbacks::Entities::TypeCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/common/plugins/can_have_callbacks/entities/type_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types:) ⇒ void

Parameters:

  • types (Array<Symbol>)


19
20
21
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/type_collection.rb', line 19

def initialize(types:)
  @types = types.map(&Entities::Type.method(:cast!))
end

Instance Attribute Details

#typesObject (readonly)

Returns the value of attribute types.



13
14
15
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/type_collection.rb', line 13

def types
  @types
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


37
38
39
40
41
42
43
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/type_collection.rb', line 37

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

  return false if types != other.types

  true
end

#contain_exactly?(other_types) ⇒ Boolean

Parameters:

  • other_types (Array<Object>)

Returns:

  • (Boolean)


27
28
29
30
31
# File 'lib/convenient_service/common/plugins/can_have_callbacks/entities/type_collection.rb', line 27

def contain_exactly?(other_types)
  other_types = other_types.map(&Entities::Type.method(:cast!))

  Utils::Array.contain_exactly?(types, other_types)
end