Module: Card::View::Options
- Included in:
- Card::View
- Defined in:
- lib/card/view/options.rb
Overview
normalizes and manages standard view options
Class Attribute Summary collapse
-
.keymap ⇒ Object
readonly
Returns the value of attribute keymap.
Instance Attribute Summary collapse
-
#normalized_options ⇒ Object
readonly
There are two primary options hashes: - @normalized_options are determined upon initialization and do not change after that.
Class Method Summary collapse
- .accessible_keys ⇒ Object
-
.all_keys ⇒ Object
all standard option keys.
- .define_getter(option_key) ⇒ Object
- .define_setter(option_key) ⇒ Object
-
.heir_keys ⇒ Object
keys that follow simple standard inheritance pattern from parent views.
-
.nest_keys ⇒ Object
keys whose values can be set by Wagneers in card nests.
Instance Method Summary collapse
- #closest_live_option(key) ⇒ Object
-
#items ⇒ Object
The following methods comprise the primary voo API.
- #live_options ⇒ Object
- #normalize_cache(value) ⇒ Object
- #normalize_editor(value) ⇒ Object
-
#slot_options ⇒ Object
options to be used in data attributes of card slots (normalized options with standard keys).
Class Attribute Details
.keymap ⇒ Object (readonly)
Returns the value of attribute keymap.
43 44 45 |
# File 'lib/card/view/options.rb', line 43 def keymap @keymap end |
Instance Attribute Details
#normalized_options ⇒ Object (readonly)
There are two primary options hashes:
- @normalized_options are determined upon initialization and do not change after that.
- @live_options are created during the "process" phase, and they can be altered via the "voo" API at any time
85 86 87 |
# File 'lib/card/view/options.rb', line 85 def @normalized_options end |
Class Method Details
.accessible_keys ⇒ Object
60 61 62 |
# File 'lib/card/view/options.rb', line 60 def accessible_keys heir_keys + [:nest_name, :nest_syntax] - [:items] end |
.all_keys ⇒ Object
all standard option keys
46 47 48 |
# File 'lib/card/view/options.rb', line 46 def all_keys @all_keys ||= keymap.each_with_object([]) { |(_k, v), a| a.push(*v) } end |
.define_getter(option_key) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/card/view/options.rb', line 64 def define_getter option_key define_method option_key do norm_method = "normalize_#{option_key}" value = [option_key] try(norm_method, value) || value end end |
.define_setter(option_key) ⇒ Object
72 73 74 75 76 |
# File 'lib/card/view/options.rb', line 72 def define_setter option_key define_method "#{option_key}=" do |value| [option_key] = value end end |
.heir_keys ⇒ Object
keys that follow simple standard inheritance pattern from parent views
56 57 58 |
# File 'lib/card/view/options.rb', line 56 def heir_keys @heir_keys ||= ::Set.new(keymap[:both]) + keymap[:heir] end |
.nest_keys ⇒ Object
keys whose values can be set by Wagneers in card nests
51 52 53 |
# File 'lib/card/view/options.rb', line 51 def nest_keys @nest_keys ||= ::Set.new(keymap[:both]) + keymap[:nest] end |
Instance Method Details
#closest_live_option(key) ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/card/view/options.rb', line 117 def closest_live_option key if .key? key [key] else (parent && parent.closest_live_option(key)) || (format.parent && format.parent.voo && format.parent.voo.closest_live_option(key)) end end |
#items ⇒ Object
The following methods comprise the primary voo API. They allow developers to read and write options dynamically
94 95 96 |
# File 'lib/card/view/options.rb', line 94 def items [:items] ||= {} end |
#live_options ⇒ Object
87 88 89 |
# File 'lib/card/view/options.rb', line 87 def @live_options ||= end |
#normalize_cache(value) ⇒ Object
107 108 109 |
# File 'lib/card/view/options.rb', line 107 def normalize_cache value value && value.to_sym end |
#normalize_editor(value) ⇒ Object
103 104 105 |
# File 'lib/card/view/options.rb', line 103 def normalize_editor value value && value.to_sym end |