Sha256: d676b00b9952b67e885fee96a9b7108d34b98b62da3b50b5491ee85893cb266d

Contents?: true

Size: 862 Bytes

Versions: 4

Compression:

Stored size: 862 Bytes

Contents

module Roar::Rails
  module Responder
    def display(model, *args)
      if representer = options.delete(:represent_items_with)
        render_items_with(model, representer) # convenience API, not recommended since it's missing hypermedia.
        return super
      end

      model = prepare_model_for(format, model, options)

      super
    end

  private
    def render_items_with(collection, representer)
      collection.map! do |mdl|  # DISCUSS: i don't like changing the method argument here.
        representer.prepare(mdl).to_hash(options) # FIXME: huh? and what about XML?
      end
    end

    module PrepareModel
      def prepare_model_for(format, model, options) # overwritten in VersionStrategy/3.0.
        controller.prepare_model_for(format, model, options)
      end
    end
    include PrepareModel
    include VersionStrategy
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
roar-rails-0.1.0 lib/roar/rails/responder.rb
roar-rails-0.0.15 lib/roar/rails/responder.rb
roar-rails-0.0.14 lib/roar/rails/responder.rb
roar-rails-0.0.13 lib/roar/rails/responder.rb