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
#default, #option, #optional, #required
Methods inherited from Base
Constructor Details
#initialize(name, req: {}, opt: {}, defaults: {}, options: {}) ⇒ Keys
Returns a new instance of Keys.
39 40 41 42 43 44 45 |
# File 'lib/definition/types/keys.rb', line 39 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.
37 38 39 |
# File 'lib/definition/types/keys.rb', line 37 def defaults @defaults end |
#ignore_extra_keys ⇒ Object
Returns the value of attribute ignore_extra_keys.
37 38 39 |
# File 'lib/definition/types/keys.rb', line 37 def ignore_extra_keys @ignore_extra_keys end |
#optional_definitions ⇒ Object
Returns the value of attribute optional_definitions.
37 38 39 |
# File 'lib/definition/types/keys.rb', line 37 def optional_definitions @optional_definitions end |
#required_definitions ⇒ Object
Returns the value of attribute required_definitions.
37 38 39 |
# File 'lib/definition/types/keys.rb', line 37 def required_definitions @required_definitions end |
Instance Method Details
#conform(value) ⇒ Object
47 48 49 |
# File 'lib/definition/types/keys.rb', line 47 def conform(value) Conformer.new(self, value).conform end |
#keys ⇒ Object
51 52 53 |
# File 'lib/definition/types/keys.rb', line 51 def keys required_definitions.keys + optional_definitions.keys end |