class Yaks::Mapper::Association
Public Class Methods
create(name, options = {})
click to toggle source
# 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
Public Instance Methods
add_to_resource(resource, parent_mapper, context)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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