Skip to content

Commit

Permalink
renaming resource to model as it is a model and not a resource.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Mar 6, 2012
1 parent e8eb969 commit 8c0f1a3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/roar/rails/responder.rb
@@ -1,25 +1,25 @@
module Roar::Rails
module Responder
def extend_with_representer!(resource, representer=nil)
representer ||= representer_for_resource(resource)
resource.extend(representer)
def extend_with_representer!(model, representer=nil)
representer ||= representer_for_resource(model)
model.extend(representer)
end

def display(resource, given_options={})
if resource.respond_to?(:map!)
resource.map! do |r|
def display(model, given_options={})
if model.respond_to?(:map!)
model.map! do |r|
extend_with_representer!(r)
r.to_hash
end
else
extend_with_representer!(resource, options.delete(:with_representer))
extend_with_representer!(model, options.delete(:with_representer))
end
super
end

private
def representer_for_resource(resource)
(resource.class.name + "Representer").constantize
def representer_for_resource(model)
(model.class.name + "Representer").constantize
end
end
end

0 comments on commit 8c0f1a3

Please sign in to comment.