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.
-
#resource_name ⇒ String
Returns the name of the resource this controller refers to.
Instance Method Details
#operation?(operation_name) ⇒ Boolean
Returns whether the provided operation is supported on this resource.
48 49 50 |
# File 'lib/pragma/rails/resource_controller.rb', line 48 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.
37 38 39 40 41 |
# File 'lib/pragma/rails/resource_controller.rb', line 37 def operation_klass(operation_name) [name.deconstantize].tap do |klass| klass << "#{resource_name}::Operation::#{operation_name.to_s.camelize}" end.join('::') end |
#resource_name ⇒ String
Returns the name of the resource this controller refers to.
20 21 22 |
# File 'lib/pragma/rails/resource_controller.rb', line 20 def resource_name name.demodulize.chomp('Controller').singularize end |