Class: Blocks::OptionsSet
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- Blocks::OptionsSet
- Defined in:
- lib/blocks/utilities/options_set.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#default_options ⇒ Object
Returns the value of attribute default_options.
-
#name ⇒ Object
Returns the value of attribute name.
-
#runtime_options ⇒ Object
Returns the value of attribute runtime_options.
-
#standard_options ⇒ Object
Returns the value of attribute standard_options.
Instance Method Summary collapse
- #add_options(*args, &block) ⇒ Object
- #current_render_strategy_and_item ⇒ Object
-
#initialize(*args, &block) ⇒ OptionsSet
constructor
A new instance of OptionsSet.
- #initialize_copy(original) ⇒ Object
- #inspect ⇒ Object
- #nested_under_indifferent_access ⇒ Object
- #render_strategies_and_items ⇒ Object
- #reset ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ OptionsSet
Returns a new instance of OptionsSet.
9 10 11 12 13 14 15 |
# File 'lib/blocks/utilities/options_set.rb', line 9 def initialize(*args, &block) = args. self.name = args.first reset , &block super(&nil) end |
Instance Attribute Details
#default_options ⇒ Object
Returns the value of attribute default_options.
7 8 9 |
# File 'lib/blocks/utilities/options_set.rb', line 7 def @default_options end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/blocks/utilities/options_set.rb', line 3 def name @name end |
#runtime_options ⇒ Object
Returns the value of attribute runtime_options.
5 6 7 |
# File 'lib/blocks/utilities/options_set.rb', line 5 def @runtime_options end |
#standard_options ⇒ Object
Returns the value of attribute standard_options.
6 7 8 |
# File 'lib/blocks/utilities/options_set.rb', line 6 def @standard_options end |
Instance Method Details
#add_options(*args, &block) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/blocks/utilities/options_set.rb', line 50 def (*args, &block) = args. caller_id = args.first runtime, defaults, standard = if .is_a?(OptionsSet) caller_id ||= .name [., ., .] else if !.is_a?(HashWithIndifferentAccess) = .with_indifferent_access end [.delete(:runtime), .delete(:defaults), ] end caller_id ||= self.name . caller_id, runtime . caller_id, standard, &block . caller_id, defaults self end |
#current_render_strategy_and_item ⇒ Object
79 80 81 |
# File 'lib/blocks/utilities/options_set.rb', line 79 def current_render_strategy_and_item render_strategies_and_items.compact.first end |
#initialize_copy(original) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/blocks/utilities/options_set.rb', line 17 def initialize_copy(original) super control_fields = ( RuntimeContext::CONTROL_VARIABLES.keys + RuntimeContext::CONTROL_VARIABLES.values ).flatten.compact self. = original..clone.except(*control_fields) self. = original..clone.except(*control_fields) self. = original..clone.except(*control_fields) end |
#inspect ⇒ Object
43 44 45 46 47 48 |
# File 'lib/blocks/utilities/options_set.rb', line 43 def inspect hash = .to_hash hash[:defaults] = if .present? hash[:runtime] = if .present? hash end |
#nested_under_indifferent_access ⇒ Object
91 92 93 |
# File 'lib/blocks/utilities/options_set.rb', line 91 def nested_under_indifferent_access self end |
#render_strategies_and_items ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/blocks/utilities/options_set.rb', line 83 def render_strategies_and_items [ .render_strategy_and_item, .render_strategy_and_item, .render_strategy_and_item ] end |
#reset ⇒ Object
73 74 75 76 77 |
# File 'lib/blocks/utilities/options_set.rb', line 73 def reset self. = HashWithRenderStrategy.new "#{name} Runtime Options" self. = HashWithRenderStrategy.new "#{name} Standard Options" self. = HashWithRenderStrategy.new "#{name} Default Options" end |
#to_s ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/blocks/utilities/options_set.rb', line 28 def to_s description = [] description << "Block Name: #{name}" description << "------------------------------" description << "Runtime Options:" description << .to_s description << "------------------------------" description << "Standard Options:" description << .to_s description << "------------------------------" description << "Default Options:" description << .to_s description.join("\n") end |