Module: Pragma::Rails::ResourceController::ClassMethods
- Defined in:
- lib/pragma/rails/resource_controller.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#operation?(operation_name) ⇒ Boolean
Returns whether the provided operation is supported on this resource.
-
#operation_klass(operation_name) ⇒ String
Returns the expected class of the provided operation on this resource.
Instance Method Details
#operation?(operation_name) ⇒ Boolean
Returns whether the provided operation is supported on this resource.
40 41 42 |
# File 'lib/pragma/rails/resource_controller.rb', line 40 def operation?(operation_name) class_exists? operation_klass(operation_name) end |
#operation_klass(operation_name) ⇒ String
Returns the expected class of the provided operation on this resource.
Note that this does not mean the operation is actually supported. Use #operation? for that.
28 29 30 31 32 33 |
# File 'lib/pragma/rails/resource_controller.rb', line 28 def operation_klass(operation_name) [name.deconstantize].tap do |klass| klass << name.demodulize.chomp('Controller').singularize klass << "Operation::#{operation_name.to_s.camelize}" end.join('::') end |