Class: Yao::Resources::OldSample
- Inherits:
-
Base
- Object
- Base
- Yao::Resources::OldSample
show all
- Defined in:
- lib/yao/resources/old_sample.rb
Instance Attribute Summary
#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
#admin=, #as_member, #client, #create, #destroy, extended, #find_by_name, #get, #list, #resources_path, #resources_path=, #return_single_on_querying=, #update, #with_resources_path
Class Method Details
.cache ⇒ Object
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
#id ⇒ Object
12
13
14
|
# File 'lib/yao/resources/old_sample.rb', line 12
def id
meter_id
end
|
#recorded_at ⇒ Object
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
|
#resource ⇒ Object
16
17
18
|
# File 'lib/yao/resources/old_sample.rb', line 16
def resource
@resource ||= Yao::Resource.get(resource_id)
end
|
#tenant ⇒ Object
20
21
22
|
# File 'lib/yao/resources/old_sample.rb', line 20
def tenant
@tenant ||= Yao::Tenant.get(project_id)
end
|
#user ⇒ Object
24
25
26
|
# File 'lib/yao/resources/old_sample.rb', line 24
def user
@user ||= Yao::User.get(user_id)
end
|