Module: Pragma::Rails::ResourceController::InstanceMethods

Defined in:
lib/pragma/rails/resource_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, *arguments, &block) ⇒ Object

Supports running missing actions.

See Also:



70
71
72
73
# File 'lib/pragma/rails/resource_controller.rb', line 70

def method_missing(method_name, *arguments, &block)
  return super unless self.class.operation?(method_name)
  run self.class.operation_klass(method_name)
end

Instance Method Details

#action_missing(action_name) ⇒ Object

If an action that does not exist is called on this controller, tries to find and run an operation on the current resource with the same name.

For instance, API::V1::PostsController#create would try to find and run API::V1::Post::Operation::Create.

Parameters:

  • action_name (String)

    name of the missing action



63
64
65
# File 'lib/pragma/rails/resource_controller.rb', line 63

def action_missing(action_name)
  send(action_name)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Supports running missing actions.

Returns:

  • (Boolean)

See Also:



78
79
80
# File 'lib/pragma/rails/resource_controller.rb', line 78

def respond_to_missing?(method_name, include_private = false)
  self.class.operation?(method_name) || super
end