Class: Blocks::OptionsSet
- Inherits:
-
HashWithRenderStrategy
- Object
- Hash
- HashWithRenderStrategy
- Blocks::OptionsSet
- Defined in:
- lib/blocks/utilities/options_set.rb
Direct Known Subclasses
Constant Summary
Constants inherited from HashWithRenderStrategy
HashWithRenderStrategy::RENDERING_STRATEGIES, HashWithRenderStrategy::RENDER_WITH_BLOCK, HashWithRenderStrategy::RENDER_WITH_PARTIAL, HashWithRenderStrategy::RENDER_WITH_PROXY
Instance Attribute Summary collapse
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ OptionsSet
constructor
A new instance of OptionsSet.
-
#inspect ⇒ Object
def to_s description = [] description << “Block Name: ##name” description << “——————————” description << “Standard Options:” description << standard_options.to_s description << “——————————” description << “Default Options:” description << default_options.to_s description.join(“n”) end.
- #render_strategy ⇒ Object
- #render_strategy_item ⇒ Object
- #renders_with_proxy? ⇒ Boolean
- #reverse_merge!(*args, &block) ⇒ Object
Methods inherited from HashWithRenderStrategy
#except, #extractable_options?, #nested_under_indifferent_access, #render_strategy_and_item, #slice, #to_hash, #to_s
Constructor Details
#initialize(*args, &block) ⇒ OptionsSet
Returns a new instance of OptionsSet.
8 9 10 11 |
# File 'lib/blocks/utilities/options_set.rb', line 8 def initialize(*args, &block) super self.name = args.first end |
Instance Attribute Details
#default_options ⇒ Object
Returns the value of attribute default_options.
6 7 8 |
# File 'lib/blocks/utilities/options_set.rb', line 6 def @default_options end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/blocks/utilities/options_set.rb', line 5 def name @name end |
Instance Method Details
#inspect ⇒ Object
def to_s
description = []
description << "Block Name: #{name}"
description << "------------------------------"
description << "Standard Options:"
description << .to_s
description << "------------------------------"
description << "Default Options:"
description << .to_s
description.join("\n")
end
25 26 27 28 29 |
# File 'lib/blocks/utilities/options_set.rb', line 25 def inspect hash = to_hash hash[:defaults] = .to_hash if .present? hash end |
#render_strategy ⇒ Object
62 63 64 |
# File 'lib/blocks/utilities/options_set.rb', line 62 def render_strategy super || .try(:render_strategy) end |
#render_strategy_item ⇒ Object
66 67 68 |
# File 'lib/blocks/utilities/options_set.rb', line 66 def render_strategy_item super || .try(:render_strategy_item) end |
#renders_with_proxy? ⇒ Boolean
58 59 60 |
# File 'lib/blocks/utilities/options_set.rb', line 58 def renders_with_proxy? render_strategy == HashWithRenderStrategy::RENDER_WITH_PROXY end |
#reverse_merge!(*args, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/blocks/utilities/options_set.rb', line 31 def reverse_merge!(*args, &block) = args. caller_id = args.first defaults, standard = if .is_a?(OptionsSet) caller_id ||= .name [., ] else [.delete(:defaults), ] end caller_id ||= self.name if standard.present? || block super caller_id, standard, &block end if defaults.present? if ! self. = HashWithRenderStrategy.new "#{name} Default Options" end .reverse_merge! caller_id, defaults end self end |