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:



80
81
82
83
# File 'lib/pragma/rails/resource_controller.rb', line 80

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



73
74
75
# File 'lib/pragma/rails/resource_controller.rb', line 73

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:



88
89
90
# File 'lib/pragma/rails/resource_controller.rb', line 88

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