Class: AMA::Entity::Mapper::Type::Any

Inherits:
AMA::Entity::Mapper::Type show all
Includes:
Mixin::Errors
Defined in:
lib/ama-entity-mapper/type/any.rb

Overview

Used as a wildcard to pass anything through

Constant Summary collapse

INSTANCE =
new

Instance Attribute Summary

Attributes inherited from AMA::Entity::Mapper::Type

#denormalizer, #enumerator, #factory, #injector, #normalizer, #type, #virtual

Instance Method Summary collapse

Methods included from Mixin::Errors

#compliance_error, #mapping_error, #raise_if_internal, #validation_error

Methods inherited from AMA::Entity::Mapper::Type

#attribute!, #instance!, #resolve, #resolved!, #resolved?, #valid!, #valid?, #violations

Methods included from Mixin::HandlerSupport

declare_handler_block_setter, declare_handler_getter, declare_handler_method, declare_handler_setter, declare_namespace_method, included

Methods included from Mixin::Reflection

#install_object_method, #method_object, #object_variable, #object_variable_exists, #object_variables, #set_object_attribute

Constructor Details

#initializeAny

Returns a new instance of Any.



14
15
16
17
18
19
# File 'lib/ama-entity-mapper/type/any.rb', line 14

def initialize
  super(self.class)
  denormalizer_block { |entity, *| entity }
  normalizer_block { |entity, *| entity }
  validator_block { |*| [] }
end

Instance Method Details

#==(other) ⇒ Object



51
52
53
# File 'lib/ama-entity-mapper/type/any.rb', line 51

def ==(other)
  eql?(other)
end

#attributesObject



27
28
29
# File 'lib/ama-entity-mapper/type/any.rb', line 27

def attributes
  {}
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/ama-entity-mapper/type/any.rb', line 47

def eql?(other)
  other.is_a?(Type)
end

#hashObject



43
44
45
# File 'lib/ama-entity-mapper/type/any.rb', line 43

def hash
  self.class.hash
end

#instance?(object) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ama-entity-mapper/type/any.rb', line 39

def instance?(object, *)
  !object.nil?
end

#parameter!Object



31
32
33
# File 'lib/ama-entity-mapper/type/any.rb', line 31

def parameter!(*)
  compliance_error('Tried to declare parameter on Any type')
end

#parametersObject



23
24
25
# File 'lib/ama-entity-mapper/type/any.rb', line 23

def parameters
  {}
end

#resolve_parameterObject



35
36
37
# File 'lib/ama-entity-mapper/type/any.rb', line 35

def resolve_parameter(*)
  self
end

#to_defObject



59
60
61
# File 'lib/ama-entity-mapper/type/any.rb', line 59

def to_def
  '*'
end

#to_sObject



55
56
57
# File 'lib/ama-entity-mapper/type/any.rb', line 55

def to_s
  'Any Type'
end