Module: MetaPresenter::Base::DelegateToController::InstanceMethods

Defined in:
lib/meta_presenter/base/delegate_to_controller.rb

Overview

:nodoc:

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)



44
45
46
47
48
49
50
# File 'lib/meta_presenter/base/delegate_to_controller.rb', line 44

def method_missing(method_name, *args, &block)
  if delegates_controller_method?(method_name)
    controller.send(method_name, *args, &block)
  else
    super
  end
end

Instance Method Details

#initialize(controller) ⇒ MetaPresenter::Base

Creates a new presenter

Parameters:

  • controller (ActionController::Base, ActionMailer::Base)

    Controller that this presenter will delegate methods to

Returns:



26
27
28
# File 'lib/meta_presenter/base/delegate_to_controller.rb', line 26

def initialize(controller)
  @controller = controller
end

#respond_to_missing?(*args) ⇒ Boolean

Check to see whether a method has been either defined by or is delegated by this presenter

Parameters:

  • *args

    method name and the other arguments

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/meta_presenter/base/delegate_to_controller.rb', line 34

def respond_to_missing?(*args)
  method_name = args.first
  delegates_controller_method?(method_name) || super
end