Class: Coupdoeil::Popover::OptionsSet
- Inherits:
-
Object
- Object
- Coupdoeil::Popover::OptionsSet
- Defined in:
- app/models/coupdoeil/popover/options_set.rb
Constant Summary collapse
- ORDERED_OPTIONS =
[ Option::Offset, Option::Placement, Option::Animation, Option::OpeningDelay, Option::Cache, Option::Loading, Option::Trigger ].freeze
- OPTION_NAMES =
ORDERED_OPTIONS.map(&:key)
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #custom_animation? ⇒ Boolean
- #dup ⇒ Object
-
#initialize(options = {}) ⇒ OptionsSet
constructor
A new instance of OptionsSet.
- #merge(options_set) ⇒ Object
- #preload? ⇒ Boolean
- #to_base36 ⇒ Object
- #to_h ⇒ Object
-
#validate! ⇒ Object
no-op.
Constructor Details
#initialize(options = {}) ⇒ OptionsSet
Returns a new instance of OptionsSet.
25 26 27 28 29 |
# File 'app/models/coupdoeil/popover/options_set.rb', line 25 def initialize( = {}) .assert_valid_keys(OPTION_NAMES) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'app/models/coupdoeil/popover/options_set.rb', line 18 def @options end |
Instance Method Details
#custom_animation? ⇒ Boolean
22 |
# File 'app/models/coupdoeil/popover/options_set.rb', line 22 def custom_animation? = [:animation].to_s == "custom" |
#dup ⇒ Object
20 |
# File 'app/models/coupdoeil/popover/options_set.rb', line 20 def dup = OptionsSet.new(.deep_dup) |
#merge(options_set) ⇒ Object
31 32 33 |
# File 'app/models/coupdoeil/popover/options_set.rb', line 31 def merge() OptionsSet.new(.merge(.)) end |
#preload? ⇒ Boolean
21 |
# File 'app/models/coupdoeil/popover/options_set.rb', line 21 def preload? = [:loading].to_s == "preload" |
#to_base36 ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/coupdoeil/popover/options_set.rb', line 48 def to_base36 @to_base36 ||= begin shift = 0 ORDERED_OPTIONS.reverse.sum do |option| bits = option.into_bits([option.key]) result = bits << shift shift += option.bit_size result end.to_s(36).freeze end end |
#to_h ⇒ Object
23 |
# File 'app/models/coupdoeil/popover/options_set.rb', line 23 def to_h = |
#validate! ⇒ Object
no-op
45 46 47 48 49 50 51 52 |
# File 'app/models/coupdoeil/popover/options_set.rb', line 45 def validate! ORDERED_OPTIONS.map do |option| next unless .key?(option.key) value = [option.key] option.new(value).validate! end end |