Class: Yaks::Mapper::Association
- Inherits:
-
Object
- Object
- Yaks::Mapper::Association
show all
- Includes:
- AbstractType, Util
- Defined in:
- lib/yaks/mapper/association.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Util
#Resolve, #camelize, #extract_options, #reject_keys, #slice_hash, #symbolize_keys, #underscore
Class Method Details
.create(name, options = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/yaks/mapper/association.rb', line 15
def self.create(name, options = {})
if options.key?(:mapper)
options = options.dup
mapper = options.delete(:mapper)
options[:item_mapper] = mapper
end
options[:name] = name
new(options)
end
|
Instance Method Details
#add_to_resource(resource, parent_mapper, context) ⇒ Object
25
26
27
28
|
# File 'lib/yaks/mapper/association.rb', line 25
def add_to_resource(resource, parent_mapper, context)
return resource unless parent_mapper.expand_value(self.if)
AssociationMapper.new(parent_mapper, self, context).call(resource)
end
|
#map_rel(policy) ⇒ Object
34
35
36
37
|
# File 'lib/yaks/mapper/association.rb', line 34
def map_rel(policy)
return rel unless rel.equal?(Undefined)
policy.derive_rel_from_association(self)
end
|
#render_as_link?(parent_mapper) ⇒ Boolean
30
31
32
|
# File 'lib/yaks/mapper/association.rb', line 30
def render_as_link?(parent_mapper)
href != Undefined && link_if != Undefined && Resolve(link_if, parent_mapper)
end
|
#resolve_association_mapper(policy) ⇒ Object
support for HasOne and HasMany
44
45
46
47
|
# File 'lib/yaks/mapper/association.rb', line 44
def resolve_association_mapper(policy)
return item_mapper unless item_mapper.equal?(Undefined)
policy.derive_mapper_from_association(self)
end
|