Class: JSONAPI::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/operation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, options)
  @operation_type = operation_type
  @resource_klass = resource_klass
  @options = options
end

Instance Attribute Details

#operation_typeObject (readonly)

Returns the value of attribute operation_type.



3
4
5
# File 'lib/jsonapi/operation.rb', line 3

def operation_type
  @operation_type
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/jsonapi/operation.rb', line 3

def options
  @options
end

#resource_klassObject (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

#processObject



11
12
13
# File 'lib/jsonapi/operation.rb', line 11

def process
  processor.process
end