Class: RKit::Decoration::Collection
- Inherits:
-
CollectionDelegator
- Object
- SimpleDelegator
- CollectionDelegator
- RKit::Decoration::Collection
- Includes:
- Base
- Defined in:
- lib/r_kit/decoration/base/collection.rb
Instance Attribute Summary collapse
-
#safe_mode ⇒ Object
Returns the value of attribute safe_mode.
Instance Method Summary collapse
Methods included from Base
#decorate, #decorated?, #initialize, #raw, #view
Methods inherited from CollectionDelegator
Methods included from Enumerable
#decorate, #decorated?, #to_grid
Methods inherited from SimpleDelegator
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CollectionDelegator
Instance Attribute Details
#safe_mode ⇒ Object
Returns the value of attribute safe_mode.
5 6 7 |
# File 'lib/r_kit/decoration/base/collection.rb', line 5 def safe_mode @safe_mode end |
Instance Method Details
#each(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/r_kit/decoration/base/collection.rb', line 11 def each &block collection.each do |object| if safe_mode && object.dont_respond_to?(:decorate) block.call object else block.call object.decorate(view_context: view) end end end |
#safe ⇒ Object
7 |
# File 'lib/r_kit/decoration/base/collection.rb', line 7 def safe() tap{ @safe_mode = true } end |
#unsafe ⇒ Object
8 |
# File 'lib/r_kit/decoration/base/collection.rb', line 8 def unsafe() tap{ @safe_mode = false } end |