Class: JSONAPI::Operation
- Inherits:
-
Object
- Object
- JSONAPI::Operation
- Defined in:
- lib/jsonapi/operation.rb
Instance Attribute Summary collapse
-
#operation_type ⇒ Object
readonly
Returns the value of attribute operation_type.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resource_klass ⇒ Object
readonly
Returns the value of attribute resource_klass.
Class Method Summary collapse
- ._processor_from_resource_type(resource_klass) ⇒ Object
- .processor_instance_for(resource_klass, operation_type, params) ⇒ Object
Instance Method Summary collapse
-
#initialize(operation_type, resource_klass, options) ⇒ Operation
constructor
A new instance of Operation.
- #process ⇒ Object
Constructor Details
#initialize(operation_type, resource_klass, options) ⇒ Operation
Returns a new instance of Operation.
5 6 7 8 9 |
# File 'lib/jsonapi/operation.rb', line 5 def initialize(operation_type, resource_klass, ) @operation_type = operation_type @resource_klass = resource_klass @options = end |
Instance Attribute Details
#operation_type ⇒ Object (readonly)
Returns the value of attribute operation_type.
3 4 5 |
# File 'lib/jsonapi/operation.rb', line 3 def operation_type @operation_type end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/jsonapi/operation.rb', line 3 def @options end |
#resource_klass ⇒ Object (readonly)
Returns the value of attribute resource_klass.
3 4 5 |
# File 'lib/jsonapi/operation.rb', line 3 def resource_klass @resource_klass end |
Class Method Details
._processor_from_resource_type(resource_klass) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/jsonapi/operation.rb', line 25 def _processor_from_resource_type(resource_klass) processor = resource_klass.name.gsub(/Resource$/,'Processor').safe_constantize if processor.nil? processor = JSONAPI.configuration.default_processor_klass end return processor end |
.processor_instance_for(resource_klass, operation_type, params) ⇒ Object
21 22 23 |
# File 'lib/jsonapi/operation.rb', line 21 def processor_instance_for(resource_klass, operation_type, params) _processor_from_resource_type(resource_klass).new(resource_klass, operation_type, params) end |
Instance Method Details
#process ⇒ Object
11 12 13 |
# File 'lib/jsonapi/operation.rb', line 11 def process processor.process end |