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:



82
83
84
85
# File 'lib/pragma/rails/resource_controller.rb', line 82

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



75
76
77
# File 'lib/pragma/rails/resource_controller.rb', line 75

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:



90
91
92
# File 'lib/pragma/rails/resource_controller.rb', line 90

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