Module: BulmaX::Dsl::Options
- Defined in:
- lib/bulma_x/dsl/options.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #assert_options_validity!(build_options) ⇒ Object
- #build_from_options(**build_options) ⇒ Object
- #class_default_options ⇒ Object
- #class_options ⇒ Object
- #option_get(name) ⇒ Object
- #option_set(name, value) ⇒ Object
Class Method Details
.included(base) ⇒ Object
89 90 91 |
# File 'lib/bulma_x/dsl/options.rb', line 89 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#assert_options_validity!(build_options) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/bulma_x/dsl/options.rb', line 116 def () .each do |key, value| raise ArgumentError, "Unknown option :#{key} on #{self.class}" unless .key?(key) class_option = [key] next if class_option.nil? || class_option.include?(value) raise ArgumentError, "Option #{key.inspect} has invalid value #{value.inspect}, expected one of #{class_option.inspect}" end end |
#build_from_options(**build_options) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/bulma_x/dsl/options.rb', line 93 def (**) @build_options = return if .nil? return if .nil? () .each_key do |attribute| value = if .key?(attribute) [attribute] else [attribute].dup end instance_variable_set(:"@#{attribute}", value) end end |
#class_default_options ⇒ Object
112 |
# File 'lib/bulma_x/dsl/options.rb', line 112 def = self.class. |
#class_options ⇒ Object
111 |
# File 'lib/bulma_x/dsl/options.rb', line 111 def = self.class. |
#option_get(name) ⇒ Object
113 |
# File 'lib/bulma_x/dsl/options.rb', line 113 def option_get(name) = instance_variable_get(:"@#{name}") |
#option_set(name, value) ⇒ Object
114 |
# File 'lib/bulma_x/dsl/options.rb', line 114 def option_set(name, value) = instance_variable_set(:"@#{name}", value) |