Class: Yao::Resources::OldSample

Inherits:
Base
  • Object
show all
Defined in:
lib/yao/resources/old_sample.rb

Instance Attribute Summary

Attributes included from RestfullyAccessible

#api_version, #service

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, #created, friendly_attributes, #initialize, map_attribute_to_attribute, map_attribute_to_resource, map_attribute_to_resources, #updated

Methods included from RestfullyAccessible

#admin=, #as_member, #client, #create, #destroy, extended, #find_by_name, #get, #list, #resources_path, #resources_path=, #return_single_on_querying=, #update, #with_resources_path

Constructor Details

This class inherits a constructor from Yao::Resources::Base

Class Method Details

.cacheObject



38
39
40
# File 'lib/yao/resources/old_sample.rb', line 38

def self.cache
  @@_cache ||= {}
end

.list(meter_name, query = {}) ⇒ Object

get /v2/meters/#id returns samples!



32
33
34
35
36
# File 'lib/yao/resources/old_sample.rb', line 32

def self.list(meter_name, query={})
  cache_key = [meter_name, *query].join
  cache[cache_key] = GET("meters/#{meter_name}", query).body unless cache[cache_key]
  return_resources(cache[cache_key])
end

Instance Method Details

#idObject



12
13
14
# File 'lib/yao/resources/old_sample.rb', line 12

def id
  meter_id
end

#recorded_atObject Also known as: timestamp



7
8
9
# File 'lib/yao/resources/old_sample.rb', line 7

def recorded_at
  Time.parse(self["recorded_at"] || self["timestamp"])
end

#resourceObject



16
17
18
# File 'lib/yao/resources/old_sample.rb', line 16

def resource
  @resource ||= Yao::Resource.get(resource_id)
end

#tenantObject



20
21
22
# File 'lib/yao/resources/old_sample.rb', line 20

def tenant
  @tenant ||= Yao::Tenant.get(project_id)
end

#userObject



24
25
26
# File 'lib/yao/resources/old_sample.rb', line 24

def user
  @user ||= Yao::User.get(user_id)
end