1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Delegate all Array methods to decorated collection

This commit is contained in:
Andrew Haines 2012-11-01 00:38:25 +00:00
parent ecd5b06274
commit 4ccf21d900

View file

@ -6,7 +6,7 @@ module Draper
attr_accessor :source, :options, :decorator_class
alias_method :to_source, :source
delegate :as_json, :collect, :map, :each, :[], :all?, :include?, :first, :last, :shift, :in_groups_of, :to => :decorated_collection
delegate :as_json, *(Array.instance_methods - Object.instance_methods), to: :decorated_collection
# @param source collection to decorate
# @param options [Hash] passed to each item's decorator (except
@ -25,7 +25,6 @@ module Draper
def decorated_collection
@decorated_collection ||= source.collect {|item| decorator_class.decorate(item, options) }
end
alias_method :to_ary, :decorated_collection
def find(*args, &block)
if block_given?