Class: SmoothOperator::HttpHandlers::Typhoeus::ORM

Inherits:
Object
  • Object
show all
Defined in:
lib/smooth_operator/http_handlers/typhoeus/orm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_class) ⇒ ORM

Returns a new instance of ORM.



9
10
11
# File 'lib/smooth_operator/http_handlers/typhoeus/orm.rb', line 9

def initialize(object_class)
  @object_class = object_class
end

Instance Attribute Details

#object_classObject (readonly)

Returns the value of attribute object_class.



7
8
9
# File 'lib/smooth_operator/http_handlers/typhoeus/orm.rb', line 7

def object_class
  @object_class
end

Instance Method Details

#make_the_call(http_verb, options, relative_path, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/smooth_operator/http_handlers/typhoeus/orm.rb', line 13

def make_the_call(http_verb, options, relative_path, &block)
  injected_hydra = options[:hydra]
  hydra = injected_hydra || ::Typhoeus::Hydra::hydra
  options[:hydra] = hydra

  remote_call = @object_class.make_the_call(http_verb, relative_path, options)

  remote_call.request.on_complete do |typhoeus_response|
    remote_call.raw_response = typhoeus_response
    yield(remote_call)
  end
  
  hydra.run if injected_hydra.blank?

  remote_call
end