Class: Definition::Types::Keys
- Includes:
- Dsl
- Defined in:
- lib/definition/types/keys.rb
Defined Under Namespace
Modules: Dsl Classes: Conformer
Instance Attribute Summary collapse
-
#defaults ⇒ Object
Returns the value of attribute defaults.
-
#ignore_extra_keys ⇒ Object
Returns the value of attribute ignore_extra_keys.
-
#optional_definitions ⇒ Object
Returns the value of attribute optional_definitions.
-
#required_definitions ⇒ Object
Returns the value of attribute required_definitions.
Attributes inherited from Base
Instance Method Summary collapse
- #conform(value) ⇒ Object
-
#initialize(name, req: {}, opt: {}, defaults: {}, options: {}) ⇒ Keys
constructor
A new instance of Keys.
- #keys ⇒ Object
Methods included from Dsl
#include, #option, #optional, #required
Methods inherited from Base
Constructor Details
#initialize(name, req: {}, opt: {}, defaults: {}, options: {}) ⇒ Keys
Returns a new instance of Keys.
63 64 65 66 67 68 69 |
# File 'lib/definition/types/keys.rb', line 63 def initialize(name, req: {}, opt: {}, defaults: {}, options: {}) super(name) self.required_definitions = req self.optional_definitions = opt self.defaults = defaults self.ignore_extra_keys = .fetch(:ignore_extra_keys, false) end |
Instance Attribute Details
#defaults ⇒ Object
Returns the value of attribute defaults.
61 62 63 |
# File 'lib/definition/types/keys.rb', line 61 def defaults @defaults end |
#ignore_extra_keys ⇒ Object
Returns the value of attribute ignore_extra_keys.
61 62 63 |
# File 'lib/definition/types/keys.rb', line 61 def ignore_extra_keys @ignore_extra_keys end |
#optional_definitions ⇒ Object
Returns the value of attribute optional_definitions.
61 62 63 |
# File 'lib/definition/types/keys.rb', line 61 def optional_definitions @optional_definitions end |
#required_definitions ⇒ Object
Returns the value of attribute required_definitions.
61 62 63 |
# File 'lib/definition/types/keys.rb', line 61 def required_definitions @required_definitions end |
Instance Method Details
#conform(value) ⇒ Object
71 72 73 |
# File 'lib/definition/types/keys.rb', line 71 def conform(value) Conformer.new(self, value).conform end |
#keys ⇒ Object
75 76 77 |
# File 'lib/definition/types/keys.rb', line 75 def keys required_definitions.keys + optional_definitions.keys end |