class Verifly::Applicator::ProcApplicatior

ProcApplicatior is used when to_proc is available. It works not only with procs, but also with hashes etc @example with a proc

Applicator.call(-> { foo }, binding_, *context) # => foo

@example with a hash

Applicator.call(Hash[foo: true], binding_, :foo) # => true
Applicator.call(Hash[foo: true], binding_, :bar) # => nil

Public Class Methods

build_class(applicable) click to toggle source

@param applicable [#to_proc] @return ProcApplicatior if applicable accepts to_proc @return [nil] otherwise

# File lib/verifly/applicator.rb, line 167
def self.build_class(applicable)
  self if applicable.respond_to?(:to_proc)
end

Public Instance Methods

call(binding_, *context) click to toggle source

@param binding_ [#instance_exec] target to apply applicable to @param context additional info to send to applicable @return application result

# File lib/verifly/applicator.rb, line 174
def call(binding_, *context)
  invoke_lambda(applicable.to_proc, binding_, *context)
end
source(*) click to toggle source

@return [String] Proc#source

# File lib/verifly/applicator.rb, line 184
def source(*)
  applicable.to_proc.source
end
source_location(*) click to toggle source

@return [String, Integer] Proc#source_location

# File lib/verifly/applicator.rb, line 179
def source_location(*)
  applicable.to_proc.source_location
end