Sha256: 79f311b574c181a424c16d053d9c29d9dfbbb7245eb4dea5c5cce8f80b996c45
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
module Draper class DecoratedEnumerableProxy include Enumerable delegate :as_json, :collect, :map, :each, :[], :all?, :include?, :first, :last, :shift, :to => :decorated_collection def initialize(collection, klass, options = {}) @wrapped_collection, @klass, @options = collection, klass, options end def decorated_collection @decorated_collection ||= @wrapped_collection.collect { |member| @klass.decorate(member, @options) } end alias_method :to_ary, :decorated_collection def method_missing (method, *args, &block) @wrapped_collection.send(method, *args, &block) end def respond_to?(method, include_private = false) super || @wrapped_collection.respond_to?(method, include_private) end def kind_of?(klass) @wrapped_collection.kind_of?(klass) || super end alias :is_a? :kind_of? def ==(other) @wrapped_collection == other end def to_s "#<DecoratedEnumerableProxy of #{@klass} for #{@wrapped_collection.inspect}>" end def context=(input) self.map { |member| member.context = input } end def source @wrapped_collection end alias_method :to_source, :source end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
draper-0.15.0 | lib/draper/decorated_enumerable_proxy.rb |
draper-0.15.0rc1 | lib/draper/decorated_enumerable_proxy.rb |
draper-0.14.0 | lib/draper/decorated_enumerable_proxy.rb |