Class: Interfacets::Shared::Entities::Specs::Handlers::Reference
- Inherits:
-
Handler
- Object
- Handler
- Interfacets::Shared::Entities::Specs::Handlers::Reference
show all
- Defined in:
- lib/interfacets/shared/entities/specs/handlers.rb
Instance Attribute Summary
Attributes inherited from Handler
#cache, #entity, #spec
Instance Method Summary
collapse
Methods inherited from Handler
#initialize, #type, #unwrap, #wrap
Instance Method Details
#build(**attributes) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/interfacets/shared/entities/specs/handlers.rb', line 67
def build(**attributes)
value = entity.instance_exec(&spec.builder)
attributes.each do |name, val|
value.send("#{name}=", val)
end
wrap(value)
end
|
#collection? ⇒ Boolean
46
47
48
|
# File 'lib/interfacets/shared/entities/specs/handlers.rb', line 46
def collection?
false
end
|
#get ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/interfacets/shared/entities/specs/handlers.rb', line 54
def get
wrap(entity.instance_exec(&spec.getter))
.tap {
@cache = {}
@cache[_1&.store] = _1
}
end
|
#reference? ⇒ Boolean
50
51
52
|
# File 'lib/interfacets/shared/entities/specs/handlers.rb', line 50
def reference?
true
end
|
#set(val) ⇒ Object
62
63
64
65
|
# File 'lib/interfacets/shared/entities/specs/handlers.rb', line 62
def set(val)
entity.instance_exec(unwrap(val), &spec.setter)
wrap(val)
end
|