Class: Blocks::HashWithRenderStrategy
- Inherits:
-
HashWithCaller
- Object
- HashWithIndifferentAccess
- HashWithCaller
- Blocks::HashWithRenderStrategy
- Defined in:
- lib/blocks/utilities/hash_with_render_strategy.rb
Direct Known Subclasses
Constant Summary collapse
- RENDER_WITH_PROXY =
:with
- RENDER_WITH_BLOCK =
:block
- RENDER_WITH_PARTIAL =
:partial
- RENDERING_STRATEGIES =
[RENDER_WITH_PROXY, RENDER_WITH_BLOCK, RENDER_WITH_PARTIAL]
Instance Attribute Summary collapse
-
#render_strategy ⇒ Object
Returns the value of attribute render_strategy.
Attributes inherited from HashWithCaller
Instance Method Summary collapse
-
#add_options(*args, &block) ⇒ Object
TODO: need to implement either merge or update to update both the hash and the callers hash.
- #initialize_copy(original) ⇒ Object
- #render_strategy_and_item ⇒ Object
- #reverse_merge(options) ⇒ Object
Methods inherited from HashWithCaller
#initialize, #nested_under_indifferent_access, #to_s
Constructor Details
This class inherits a constructor from Blocks::HashWithCaller
Instance Attribute Details
#render_strategy ⇒ Object
Returns the value of attribute render_strategy.
3 4 5 |
# File 'lib/blocks/utilities/hash_with_render_strategy.rb', line 3 def render_strategy @render_strategy end |
Instance Method Details
#add_options(*args, &block) ⇒ Object
TODO: need to implement either merge or update to update
both the hash and the callers hash
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/blocks/utilities/hash_with_render_strategy.rb', line 29 def (*args, &block) = args. if !.is_a?(HashWithIndifferentAccess) = .with_indifferent_access end [:block] = block if block if render_strategy.nil? self.render_strategy = if .is_a?(HashWithRenderStrategy) .render_strategy else RENDERING_STRATEGIES.detect {|render_strategy| [render_strategy].present? } end end super(*args, ) end |
#initialize_copy(original) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/blocks/utilities/hash_with_render_strategy.rb', line 11 def initialize_copy(original) super self.callers = original.callers.clone self.render_strategy = nil RENDERING_STRATEGIES.each do |rs| self.delete(rs) end end |
#render_strategy_and_item ⇒ Object
46 47 48 |
# File 'lib/blocks/utilities/hash_with_render_strategy.rb', line 46 def render_strategy_and_item [render_strategy, self[render_strategy]] if render_strategy end |
#reverse_merge(options) ⇒ Object
22 23 24 |
# File 'lib/blocks/utilities/hash_with_render_strategy.rb', line 22 def reverse_merge() self.clone.tap {|cloned| cloned.() } end |