Class: Remap::Constructor::Argument
- Inherits:
-
Concrete
- Object
- Concrete
- Remap::Constructor::Argument
- Defined in:
- lib/remap/constructor/argument.rb
Overview
Allows a class (target) to be called with a regular argument
Instance Method Summary collapse
Instance Method Details
#call(state) ⇒ State
Uses the Remap::Constructor#method method to initialize Remap::Constructor#target with state Target is only called if state is defined
Used by Base to define constructors for mapped data
Fails if Remap::Constructor#target does not respond to Remap::Constructor#method Fails if Remap::Constructor#target cannot be called with state
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/remap/constructor/argument.rb', line 30 def call(state) super.fmap do |input| target.public_send(id, input) rescue ArgumentError => e raise e.exception("Failed to create [%p] with input [%s] (%s)" % [ target, input, input.class ]) end end |
#strategy ⇒ :argument
10 |
# File 'lib/remap/constructor/argument.rb', line 10 attribute :strategy, Value(:argument), default: :argument |