Class: AMA::Entity::Mapper::Type::Parameter
- Inherits:
-
Object
- Object
- AMA::Entity::Mapper::Type::Parameter
show all
- Includes:
- Mixin::Errors
- Defined in:
- lib/ama-entity-mapper/type/parameter.rb
Overview
This class represents parameter type - an unknown-until-runtime type that belongs to particular other type. For example, Hash<Symbol, Integer> may be described as Type(Hash) with parameters _key: Symbol and _value: Integer
Instance Attribute Summary collapse
Instance Method Summary
collapse
#compliance_error, #mapping_error, #raise_if_internal, #validation_error
Constructor Details
#initialize(owner, id) ⇒ Parameter
Returns a new instance of Parameter.
25
26
27
28
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 25
def initialize(owner, id)
@owner = owner
@id = id
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
21
22
23
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 21
def id
@id
end
|
#owner ⇒ Object
Returns the value of attribute owner.
18
19
20
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 18
def owner
@owner
end
|
18
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 18
attr_reader :owner
|
Instance Method Details
#==(other) ⇒ Object
63
64
65
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 63
def ==(other)
eql?(other)
end
|
#eql?(other) ⇒ Boolean
58
59
60
61
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 58
def eql?(other)
return false unless other.is_a?(self.class)
@id == other.id && @owner == other.owner
end
|
#hash ⇒ Object
54
55
56
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 54
def hash
@owner.hash ^ @id.hash
end
|
#instance?(_) ⇒ Boolean
30
31
32
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 30
def instance?(_)
false
end
|
#resolve_parameter ⇒ Object
34
35
36
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 34
def resolve_parameter(*)
self
end
|
#resolved!(context = nil) ⇒ Object
42
43
44
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 42
def resolved!(context = nil)
compliance_error("Type #{self} is not resolved", context: context)
end
|
#resolved? ⇒ Boolean
38
39
40
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 38
def resolved?
false
end
|
#to_def ⇒ Object
50
51
52
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 50
def to_def
"#{owner.type}.#{id}"
end
|
#to_s ⇒ Object
46
47
48
|
# File 'lib/ama-entity-mapper/type/parameter.rb', line 46
def to_s
"Parameter #{owner.type}.#{id}"
end
|