lib/yaks/mapper.rb in yaks-0.6.0.alpha.1 vs lib/yaks/mapper.rb in yaks-0.6.0

- old
+ new

@@ -4,12 +4,14 @@ class Mapper extend ClassMethods, Forwardable include Util, FP def_delegators 'self.class', :config - def_delegators :config, :attributes, :links, :associations + def_delegators :config, :attributes, :links, :associations, :controls + config Config.new + attr_reader :object, :context def initialize(context) @context = context end @@ -39,11 +41,12 @@ return NullResource.new if object.nil? [ :map_attributes, :map_links, - :map_subresources + :map_subresources, + :map_controls ].inject(Resource.new(type: mapper_name)) do |resource, method| send(method, resource) end end @@ -67,9 +70,15 @@ end def map_subresources(resource) associations.inject(resource) do |res, association| association.add_to_resource(res, self, context) + end + end + + def map_controls(resource) + controls.inject(resource) do |res, control| + control.add_to_resource(res, self, context) end end end end