Module: Card::View::Options
- Included in:
- Card::View
- Defined in:
- lib/card/view/options.rb
Class Attribute Summary collapse
-
.keymap ⇒ Object
readonly
Returns the value of attribute keymap.
Instance Attribute Summary collapse
-
#normalized_options ⇒ Hash
readonly
- @normalized_options are determined upon initialization and do not change after that.
Class Method Summary collapse
-
.accessible_keys ⇒ Array
Keys that can be read or written via accessors.
-
.all_keys ⇒ Array
all standard option keys.
-
.carditect_keys ⇒ Array
keys whose values can be set by Deckers in card nests.
- .define_getter(option_key) ⇒ Object
- .define_setter(option_key) ⇒ Object
-
.heir_keys ⇒ Array
keys that follow simple standard inheritance pattern from parent views.
Instance Method Summary collapse
- #closest_live_option(key) ⇒ Object
-
#items ⇒ Hash
"items", the option used to configure views of each of a list of cards, is currently the only Hash option (thus this accessor override).
-
#live_options ⇒ Hash
- @live_options are dynamic and can be altered by the "voo" API at any time.
- #normalize_cache(value) ⇒ Object
-
#normalize_editor(value) ⇒ Object
ACCESSOR_HELPERS methods that follow the normalize_#key pattern are called by accessors (arguably that should be done during normalization!).
-
#slot_options ⇒ Hash
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.
54 55 56 |
# File 'lib/card/view/options.rb', line 54 def keymap @keymap end |
Instance Attribute Details
#normalized_options ⇒ Hash (readonly)
- @normalized_options are determined upon initialization and do not change after that.
111 112 113 |
# File 'lib/card/view/options.rb', line 111 def @normalized_options end |
Class Method Details
.accessible_keys ⇒ Array
Keys that can be read or written via accessors
78 79 80 81 82 83 84 |
# File 'lib/card/view/options.rb', line 78 def accessible_keys all_keys - [ # (all but the following) :view, # view is accessed as requested_view or ok_view and cannot be directly manipulated :show, :hide # these have a more extensive API (see Card::View::Visibility) #:items, ] end |
.all_keys ⇒ Array
all standard option keys
60 61 62 |
# File 'lib/card/view/options.rb', line 60 def all_keys @all_keys ||= keymap.each_with_object([]) { |(_k, v), a| a.push(*v) } end |
.carditect_keys ⇒ Array
keys whose values can be set by Deckers in card nests
66 67 68 |
# File 'lib/card/view/options.rb', line 66 def carditect_keys @carditect_keys ||= ::Set.new(keymap[:both]) + keymap[:carditect] end |
.define_getter(option_key) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/card/view/options.rb', line 86 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
94 95 96 97 98 |
# File 'lib/card/view/options.rb', line 94 def define_setter option_key define_method "#{option_key}=" do |value| [option_key] = value end end |
.heir_keys ⇒ Array
keys that follow simple standard inheritance pattern from parent views
72 73 74 |
# File 'lib/card/view/options.rb', line 72 def heir_keys @heir_keys ||= ::Set.new(keymap[:both]) + keymap[:heir] end |
Instance Method Details
#closest_live_option(key) ⇒ Object
144 145 146 147 148 149 150 |
# File 'lib/card/view/options.rb', line 144 def closest_live_option key if .key? key [key] elsif (ancestor = next_ancestor) ancestor.closest_live_option key end end |
#items ⇒ Hash
"items", the option used to configure views of each of a list of cards, is currently the only Hash option (thus this accessor override)
133 134 135 |
# File 'lib/card/view/options.rb', line 133 def items [:items] ||= {} end |
#live_options ⇒ Hash
- @live_options are dynamic and can be altered by the "voo" API at any time. Such alterations are NOT used in stubs
116 117 118 |
# File 'lib/card/view/options.rb', line 116 def @live_options ||= end |
#normalize_cache(value) ⇒ Object
160 161 162 |
# File 'lib/card/view/options.rb', line 160 def normalize_cache value value && value.to_sym end |
#normalize_editor(value) ⇒ Object
ACCESSOR_HELPERS methods that follow the normalize_#key pattern are called by accessors (arguably that should be done during normalization!)
156 157 158 |
# File 'lib/card/view/options.rb', line 156 def normalize_editor value value && value.to_sym end |