Class: Oprah::ControllerHelpers::ViewContextProxy

Inherits:
ActiveSupport::ProxyObject
  • Object
show all
Defined in:
lib/oprah/controller_helpers.rb

Overview

A proxy class to delegate method calls to view contexts in presenters to the most recently created view context by #view_context.

`ViewContextProxy` objects are automatically created in #present and #present_many and shouldn't have to be created manually.

Since:

  • 0.1.3

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ ViewContextProxy

Returns a new instance of ViewContextProxy.

Parameters:

  • controller (ActionController::Base)

    The controller to delegate to.

Since:

  • 0.1.3


17
18
19
# File 'lib/oprah/controller_helpers.rb', line 17

def initialize(controller)
  @controller = controller
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object

Delegates all method calls to the `ActionView::Base` returned from Oprah::ControllerHelpers#oprah_view_context.

Since:

  • 0.1.3


23
24
25
# File 'lib/oprah/controller_helpers.rb', line 23

def method_missing(meth, *args, &block)
  @controller.oprah_view_context.__send__(meth, *args, &block)
end