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.
58 59 60 61 62 63 64 |
# File 'lib/definition/types/keys.rb', line 58 def initialize(name, req: {}, opt: {}, defaults: {}, options: {}) super(name) self.required_definitions = req.map { |key, definition| { key: key, definition: definition } } self.optional_definitions = opt.map { |key, definition| { key: key, definition: definition } } self.defaults = defaults self.ignore_extra_keys = .fetch(:ignore_extra_keys, false) end |
Instance Attribute Details
#defaults ⇒ Object
Returns the value of attribute defaults.
56 57 58 |
# File 'lib/definition/types/keys.rb', line 56 def defaults @defaults end |
#ignore_extra_keys ⇒ Object
Returns the value of attribute ignore_extra_keys.
56 57 58 |
# File 'lib/definition/types/keys.rb', line 56 def ignore_extra_keys @ignore_extra_keys end |
#optional_definitions ⇒ Object
Returns the value of attribute optional_definitions.
56 57 58 |
# File 'lib/definition/types/keys.rb', line 56 def optional_definitions @optional_definitions end |
#required_definitions ⇒ Object
Returns the value of attribute required_definitions.
56 57 58 |
# File 'lib/definition/types/keys.rb', line 56 def required_definitions @required_definitions end |
Instance Method Details
#conform(value) ⇒ Object
66 67 68 |
# File 'lib/definition/types/keys.rb', line 66 def conform(value) Conformer.new(self, value).conform end |
#keys ⇒ Object
70 71 72 |
# File 'lib/definition/types/keys.rb', line 70 def keys (required_definitions + optional_definitions).map { |hash| hash[:key] } end |