Class: Verifly::Applicator Abstract

Inherits:
Object
  • Object
show all
Extended by:
ClassBuilder::Mixin
Defined in:
lib/verifly/applicator.rb

Overview

This class is abstract.

implement ‘#call`, `#source` and `#source_location`

Applies “applicable” objects to given bindings (applicable objects are named based on their use, currently any object is applicable).

This class uses ClassBuilder system. When reading the code, we suggest starting from ‘.call’ method

See Also:

Defined Under Namespace

Classes: InstanceEvaluator, MethodExtractor, ProcApplicatior, Proxy, Quoter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassBuilder::Mixin

build, build_class, buildable_classes=

Constructor Details

#initialize(applicable) ⇒ Applicator

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO:

add more examples right here

Always use build instead of new

Parameters:

  • applicable (applicable)

    see examples in definitions of sublclasses



234
235
236
# File 'lib/verifly/applicator.rb', line 234

def initialize(applicable)
  self.applicable = applicable
end

Instance Attribute Details

#applicableapplicable

wrapped applicable object

Returns:

  • (applicable)

    the current value of applicable



13
14
15
# File 'lib/verifly/applicator.rb', line 13

def applicable
  @applicable
end

Class Method Details

.call(applicable, binding_, *context) ⇒ Object

Applies applicable on binding_ with context

Parameters:

  • applicable (applicable)

    see examples in definitions of subclasses

  • binding_ (#instance_exec)

    where should applicable be applied. It could be either a generic object, where it would be ‘instance_exec`uted, or a binding_

  • context

    geneneric data you want to pass to applicable function. If applicable cannot accept params, context will not be sent

Returns:

  • application result



225
226
227
# File 'lib/verifly/applicator.rb', line 225

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

Instance Method Details

#==(other) ⇒ Boolean

Returns true if applicable matches, false otherwise.

Parameters:

Returns:

  • (Boolean)

    true if applicable matches, false otherwise



240
241
242
# File 'lib/verifly/applicator.rb', line 240

def ==(other)
  applicable == other.applicable
end

#call(binding_, *context) ⇒ Object

This method is abstract.

Applies applicable on binding_ with context

Parameters:

  • binding_ (#instance_exec)

    binding to be used for applying

  • context

    param that will be passed if requested

Returns:

  • application result



# File 'lib/verifly/applicator.rb', line 244

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

This method is abstract.

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)



# File 'lib/verifly/applicator.rb', line 251