Module: Trestle::EvaluationContext

Included in:
Adapters::Adapter, Navigation::Block::Evaluator, Scopes::Block::Evaluator
Defined in:
lib/trestle/evaluation_context.rb

Overview

This module facilitiates the delegation of missing methods to a given @context variable.

This allows code such as adapter and navigation blocks to be evaluated with access to methods from both the Adapter/Navigation instance, as well as the controller/view from where they are invoked.

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (protected)

Missing methods are called on the given context if available.

We include private methods as methods such as current_user are usually declared as private or protected.



12
13
14
15
16
17
18
# File 'lib/trestle/evaluation_context.rb', line 12

def method_missing(name, *args, &block)
  if @context && @context.respond_to?(name, true)
    @context.send(name, *args, &block)
  else
    super
  end
end