Class: Dry::Struct::Constructor
- Inherits:
-
Object
- Object
- Dry::Struct::Constructor
- Includes:
- Types::Type
- Defined in:
- lib/dry/struct/constructor.rb
Instance Attribute Summary collapse
- #fn ⇒ #call readonly
- #type ⇒ #call readonly
Instance Method Summary collapse
- #call(input) ⇒ Object (also: #[])
-
#initialize(type, options = {}, &block) ⇒ Constructor
constructor
A new instance of Constructor.
Constructor Details
#initialize(type, options = {}, &block) ⇒ Constructor
Returns a new instance of Constructor.
16 17 18 19 |
# File 'lib/dry/struct/constructor.rb', line 16 def initialize(type, = {}, &block) @type = type @fn = .fetch(:fn, block) end |
Instance Attribute Details
#type ⇒ #call (readonly)
11 12 13 |
# File 'lib/dry/struct/constructor.rb', line 11 def type @type end |
Instance Method Details
#call(input) ⇒ Object Also known as: []
23 24 25 |
# File 'lib/dry/struct/constructor.rb', line 23 def call(input) type[fn[input]] end |