Class: ServiceOperation::Params::EnumerableOf

Inherits:
EnumType
  • Object
show all
Defined in:
lib/service_operation/params/types.rb

Overview

Matches an Enumerable with specific sub types

Examples:

EnumerableOf.new(String, Integer)

Direct Known Subclasses

ArrayOf

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from EnumType

#==, #inspect

Constructor Details

#initialize(*args) ⇒ EnumerableOf

Returns a new instance of EnumerableOf.



75
76
77
78
79
# File 'lib/service_operation/params/types.rb', line 75

def initialize(*args)
  @element_type = args.length == 1 ? args.first : Any.new(args)

  super
end

Instance Attribute Details

#element_typeObject (readonly)

Returns the value of attribute element_type.



73
74
75
# File 'lib/service_operation/params/types.rb', line 73

def element_type
  @element_type
end

Instance Method Details

#===(other) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/service_operation/params/types.rb', line 82

def ===(other)
  type === other && other.all? { |element| element_type === element }
end

#nameObject



86
87
88
# File 'lib/service_operation/params/types.rb', line 86

def name
  "#{super}Of(#{element_type.name})"
end

#typeObject



90
91
92
# File 'lib/service_operation/params/types.rb', line 90

def type
  Enumerable
end