Class: Verifly::Applicator::Proxy

Inherits:
Verifly::Applicator show all
Defined in:
lib/verifly/applicator.rb

Overview

Proxy is used when applicable itself is an instance of Applicator. It just delegates #call method to applicable

Examples:

Applicator.call(Applicator.build(:foo), binding_, *context)
# => Applicator.call(:foo, binding_, *context)

Instance Attribute Summary

Attributes inherited from Verifly::Applicator

#applicable

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Verifly::Applicator

#==, call, #initialize

Methods included from ClassBuilder::Mixin

#build, #build_class, #buildable_classes=

Constructor Details

This class inherits a constructor from Verifly::Applicator

Class Method Details

.build_class(applicable) ⇒ Object

Parameters:

Returns:

  • Proxy if applicable is an instance of Applicator

  • (nil)

    otherwise



23
24
25
# File 'lib/verifly/applicator.rb', line 23

def self.build_class(applicable)
  self if applicable.is_a?(Applicator)
end

Instance Method Details

#call(binding_, *context) ⇒ Object

Returns application result.

Parameters:

  • binding_ (#instance_exec)

    target to apply applicable

  • context

    additional info to send it to applicable

Returns:

  • application result



30
31
32
# File 'lib/verifly/applicator.rb', line 30

def call(binding_, *context)
  applicable.call(binding_, *context)
end

#source(binding_) ⇒ String?

Returns callback (not it’s defenition) source code.

Parameters:

  • binding_ (#instance_exec)

    binding to find relative source

Returns:

  • (String?)

    callback (not it’s defenition) source code



42
43
44
# File 'lib/verifly/applicator.rb', line 42

def source(binding_)
  applicable.source(binding_)
end

#source_location(binding_) ⇒ [String, Integer]?

Returns (file, line) location of calblack source (if exists).

Parameters:

  • binding_ (#instance_exec)

    binding to find relative source

Returns:

  • ([String, Integer]?)

    (file, line) location of calblack source (if exists)



36
37
38
# File 'lib/verifly/applicator.rb', line 36

def source_location(binding_)
  applicable.source_location(binding_)
end