Class: Remap::Constructor

Inherits:
Dry::Interface
  • Object
show all
Defined in:
lib/remap/constructor.rb,
lib/remap/constructor/none.rb,
lib/remap/constructor/keyword.rb,
lib/remap/constructor/argument.rb

Defined Under Namespace

Classes: Argument, Keyword, None

Instance Method Summary collapse

Instance Method Details

#call(state) ⇒ State

Ensures #target responds to #method Returns an error state unless above is true

Parameters:

Returns:



17
18
19
20
21
22
23
# File 'lib/remap/constructor.rb', line 17

def call(state)
  state.tap do
    unless target.respond_to?(id)
      raise ArgumentError, "Target [#{target}] does not respond to [#{id}]"
    end
  end
end

#methodSymbol

Returns:

  • (Symbol)


9
# File 'lib/remap/constructor.rb', line 9

attribute :method, Symbol, default: :new

#targetAny

Returns:

  • (Any)


6
# File 'lib/remap/constructor.rb', line 6

attribute :target, Types::Any, not_eql: Nothing

#to_procProc

Returns:

  • (Proc)


26
27
28
# File 'lib/remap/constructor.rb', line 26

def to_proc
  method(:call).to_proc
end