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:



14
15
16
17
18
19
20
# File 'lib/remap/constructor.rb', line 14

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

#idObject



22
23
24
# File 'lib/remap/constructor.rb', line 22

def id
  attributes.fetch(:method)
end

#to_procObject



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

def to_proc
  method(:call).to_proc
end