Class: HipstaScale::NewRelic
- Inherits:
-
Object
- Object
- HipstaScale::NewRelic
- Defined in:
- lib/hipsta_scale/new_relic.rb
Constant Summary collapse
- BASE_URL =
'https://api.newrelic.com/api/v1'
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #busy_percent ⇒ Object
- #expire! ⇒ Object
- #fetch ⇒ Object
-
#initialize(app) ⇒ NewRelic
constructor
A new instance of NewRelic.
Constructor Details
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
9 10 11 |
# File 'lib/hipsta_scale/new_relic.rb', line 9 def app @app end |
Instance Method Details
#busy_percent ⇒ Object
15 16 17 |
# File 'lib/hipsta_scale/new_relic.rb', line 15 def busy_percent fetch.busy_percent end |
#expire! ⇒ Object
19 20 21 |
# File 'lib/hipsta_scale/new_relic.rb', line 19 def expire! @_cache = nil end |
#fetch ⇒ Object
23 24 25 26 27 28 |
# File 'lib/hipsta_scale/new_relic.rb', line 23 def fetch return @_cache unless @_cache.nil? json = RestClient.get(url, 'x-api-key' => app.new_relic_key) response = JSON.parse(json) @_cache = OpenStruct.new(response.first) end |