Class: Dry::Struct::Constructor
- Inherits:
-
Object
- Object
- Dry::Struct::Constructor
- 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.
15 16 17 18 |
# File 'lib/dry/struct/constructor.rb', line 15 def initialize(type, = {}, &block) @type = type @fn = .fetch(:fn, block) end |
Instance Attribute Details
#type ⇒ #call (readonly)
10 11 12 |
# File 'lib/dry/struct/constructor.rb', line 10 def type @type end |
Instance Method Details
#call(input) ⇒ Object Also known as: []
22 23 24 |
# File 'lib/dry/struct/constructor.rb', line 22 def call(input) type[fn[input]] end |