Class: Remap::Constructor::Keyword
- Inherits:
-
Concrete
- Object
- Concrete
- Remap::Constructor::Keyword
- Defined in:
- lib/remap/constructor/keyword.rb
Overview
Allows a class (target) to be called with keyword arguments
Instance Method Summary collapse
-
#call(state) ⇒ State
Calls #target as with keyword arguments.
- #strategy ⇒ :keyword
Instance Method Details
#call(state) ⇒ State
Calls Remap::Constructor#target as with keyword arguments
Fails if Remap::Constructor#target does not respond to Remap::Constructor#method Fails if Remap::Constructor#target cannot be called with state
Used by Base to define constructors for mapped data
29 30 31 32 33 34 35 36 37 |
# File 'lib/remap/constructor/keyword.rb', line 29 def call(state) super.fmap do |input| unless input.is_a?(Hash) raise ArgumentError, "Expected Hash, got #{input.class}" end target.public_send(id, **input) end end |
#strategy ⇒ :keyword
10 |
# File 'lib/remap/constructor/keyword.rb', line 10 attribute :strategy, Value(:keyword) |