Class: Dillo::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/dillo.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/dillo.rb', line 37
def initialize
@connection = Faraday.new(:url => self.class.root) do |builder|
builder.use SocrataAppTokenMiddleware
builder.use Dillo::Response::RaiseClientError
builder.response :json, :content_type => /\bjson$/
if Dillo.debug
builder.response :logger
end
builder.adapter Faraday.default_adapter
end
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
35
36
37
|
# File 'lib/dillo.rb', line 35
def connection
@connection
end
|
Class Method Details
.root ⇒ Object
31
32
33
|
# File 'lib/dillo.rb', line 31
def self.root
"http://data.austintexas.gov"
end
|
Instance Method Details
#body ⇒ Object
52
53
54
55
56
57
|
# File 'lib/dillo.rb', line 52
def body
@body ||= connection.get(path) do |request|
prepare_request(request)
end.body
end
|
#inspect ⇒ Object
70
71
72
|
# File 'lib/dillo.rb', line 70
def inspect
"#<#{self.class.name} #{self.class.root}#{path}>"
end
|
#json ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/dillo.rb', line 62
def json
json ||= body
end
|
#prepare_request(request) ⇒ Object
59
60
|
# File 'lib/dillo.rb', line 59
def prepare_request(request)
end
|