Module: Opener::Client::Processor

Defined in:
lib/opener/client/processor.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



4
5
6
# File 'lib/opener/client/processor.rb', line 4

def host
  @host
end

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/opener/client/processor.rb', line 6

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#endpointObject



34
35
36
# File 'lib/opener/client/processor.rb', line 34

def endpoint
  [host, processor].join("/")
end

#initialize(host) ⇒ Object



18
19
20
# File 'lib/opener/client/processor.rb', line 18

def initialize(host)
  @host = host
end

#optionsObject



38
39
40
# File 'lib/opener/client/processor.rb', line 38

def options
  {}
end

#process(input, callbacks = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/opener/client/processor.rb', line 22

def process(input, callbacks=nil)
  opts = {:input=>input}.merge(options)
  opts[:'callbacks[]'] = callbacks unless callbacks.nil?

  response = HTTPClient.post(endpoint, opts)
  if response.status == 500
    raise "Internal Server error in: #{self.class.name}, #{response.body}"
  else
    return response.body
  end
end