Module: Definition::Types::Keys::Dsl
- Included in:
- Definition::Types::Keys
- Defined in:
- lib/definition/types/keys.rb
Instance Method Summary collapse
- #include(other) ⇒ Object
- #option(option_name) ⇒ Object
- #optional(key, definition, **opts) ⇒ Object
- #required(key, definition) ⇒ Object
Instance Method Details
#include(other) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/definition/types/keys.rb', line 29 def include(other) raise ArgumentError.new("Included Definition can only be a Keys Definition") unless other.is_a?(Types::Keys) ensure_keys_do_not_interfere(other) required_definitions.merge!(other.required_definitions) optional_definitions.merge!(other.optional_definitions) defaults.merge!(other.defaults) end |
#option(option_name) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/definition/types/keys.rb', line 20 def option(option_name) case option_name when :ignore_extra_keys self.ignore_extra_keys = true else raise "Option #{option_name} is not defined" end end |
#optional(key, definition, **opts) ⇒ Object
15 16 17 18 |
# File 'lib/definition/types/keys.rb', line 15 def optional(key, definition, **opts) optional_definitions[key] = definition default(key, opts[:default]) if opts.key?(:default) end |
#required(key, definition) ⇒ Object
11 12 13 |
# File 'lib/definition/types/keys.rb', line 11 def required(key, definition) required_definitions[key] = definition end |