Class: RKit::Decoration::Collection

Inherits:
CollectionDelegator show all
Includes:
Base
Defined in:
lib/r_kit/decoration/base/collection.rb

Instance Method Summary collapse

Methods included from Base

#after_initialize!, #decorate, #decorated?, included, #method_missing, #need_decoration?, #raw, #view

Methods inherited from CollectionDelegator

#method_missing

Methods inherited from SimpleDelegator

#===, getobj_attr_reader

Constructor Details

#initialize(*args) ⇒ Collection

Returns a new instance of Collection.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/r_kit/decoration/base/collection.rb', line 4

def initialize *args
  super

  self.singleton_class.send :override_method, :each do |&block|
    __olddef__ do |object|
      if object.need_decoration?
        block.call object.decorate(view_context: view)
      else
        block.call object
      end

    end
  end

  self.extend Enumerable
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RKit::Decoration::Base