Class: Dry::Data::Default
- Inherits:
-
Object
- Object
- Dry::Data::Default
- Includes:
- Decorator, TypeBuilder
- Defined in:
- lib/dry/data/default.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes included from Decorator
Instance Method Summary collapse
- #call(input) ⇒ Object (also: #[])
-
#initialize(type, options) ⇒ Default
constructor
A new instance of Default.
Methods included from TypeBuilder
#constrained, #default, #enum, #optional, #safe, #|
Methods included from Decorator
#constructor, #respond_to_missing?, #valid?, #with
Constructor Details
#initialize(type, options) ⇒ Default
Returns a new instance of Default.
11 12 13 14 |
# File 'lib/dry/data/default.rb', line 11 def initialize(type, ) super @value = .fetch(:value) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Dry::Data::Decorator
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/dry/data/default.rb', line 9 def value @value end |
Instance Method Details
#call(input) ⇒ Object Also known as: []
16 17 18 |
# File 'lib/dry/data/default.rb', line 16 def call(input) input.nil? ? value : type[input] end |