Class: FOaaS::FO

Inherits:
PayDirt::Base
  • Object
show all
Defined in:
lib/foaas/f_o.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FO

Returns a new instance of FO.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/foaas/f_o.rb', line 3

def initialize(options = {})
  options = {
    resource:     'off',
    name:         nil,
    from:         'me',
    root_url:     'http://foaas.herokuapp.com',
    http_headers: {
      "Accept"       => "application/json",
    }
  }.merge(options)

  options.merge!({
    uri: [
      options[:root_url],
      options[:resource],
      options[:name],
      options[:from]
    ].compact.join("/")
  })

  [:root_url, :resource, :name, :from].map do |o|
    options.delete o
  end

  load_options(:uri, :http_headers, options)
end

Instance Method Details

#execute!Object



30
31
32
# File 'lib/foaas/f_o.rb', line 30

def execute!
  return result(true, JSON.parse(open(@uri, @http_headers).read))
end