Module: MetaPresenter::Base::DelegateAllTo::InstanceMethods

Defined in:
lib/meta_presenter/base/delegate_all_to.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)

Use metaprogramming to delegate all methods



37
38
39
40
41
42
43
44
45
# File 'lib/meta_presenter/base/delegate_all_to.rb', line 37

def method_missing(method_name, *args, &block)
  # If `delegate_all_to` has been set up for the method name
  # then delegate to it, otherwise pass it up the food chain
  if !delegating_all_to? && delegate_all_responds_to?(method_name)
    delegate_all_to.send(method_name, *args, &block)
  else
    super
  end
end

Instance Method Details

#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)


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

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