Sha256: 14027a4dcfc4886987444d4338aac35c24d867149817b1998ba59872ccc09a2b
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
module Yaks class Mapper class Association include Attribs.new( name: Undefined, item_mapper: Undefined, rel: Undefined, href: Undefined, link_if: Undefined, if: Undefined ), Util, AbstractType 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 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 def render_as_link?(parent_mapper) href != Undefined && link_if != Undefined && Resolve(link_if, parent_mapper) end def map_rel(policy) return rel unless rel.equal?(Undefined) policy.derive_rel_from_association(self) end # @param object # @param context abstract_method :map_resource # support for HasOne and HasMany def resolve_association_mapper(policy) return item_mapper unless item_mapper.equal?(Undefined) policy.derive_mapper_from_association(self) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
yaks-0.13.0 | lib/yaks/mapper/association.rb |
yaks-0.12.0 | lib/yaks/mapper/association.rb |
yaks-0.11.0 | lib/yaks/mapper/association.rb |
yaks-0.10.0 | lib/yaks/mapper/association.rb |