Class: Yao::Resources::OldSample
Instance Attribute Summary
#service
Class Method Summary
collapse
Instance Method Summary
collapse
included, #tenant
Methods inherited from Base
#[], #[]=, #created, friendly_attributes, #initialize, map_attribute_to_attribute, map_attribute_to_resource, map_attribute_to_resources, #to_hash, #updated
#admin=, #api_version, #api_version=, #as_member, #client, #create, #destroy, extended, #find_by_name, #get, #get!, #list, #resources_path, #resources_path=, #return_single_on_querying, #return_single_on_querying=, #update
Class Method Details
.cache ⇒ Object
36
37
38
|
# File 'lib/yao/resources/old_sample.rb', line 36
def self.cache
@@_cache ||= {}
end
|
.list(meter_name, query = {}) ⇒ Object
get /v2/meters/#id returns samples!
30
31
32
33
34
|
# File 'lib/yao/resources/old_sample.rb', line 30
def self.list(meter_name, query={})
cache_key = [meter_name, *query].join
cache[cache_key] = GET("#{self.api_version}/meters/#{meter_name}", query).body unless cache[cache_key]
cache[cache_key].map{|d| new(d) }
end
|
Instance Method Details
#id ⇒ Object
14
15
16
|
# File 'lib/yao/resources/old_sample.rb', line 14
def id
message_id
end
|
#recorded_at ⇒ Object
Also known as:
timestamp
9
10
11
|
# File 'lib/yao/resources/old_sample.rb', line 9
def recorded_at
Time.parse(self["recorded_at"] || self["timestamp"])
end
|
#resource ⇒ Object
18
19
20
|
# File 'lib/yao/resources/old_sample.rb', line 18
def resource
@resource ||= Yao::Resource.get(resource_id)
end
|
#user ⇒ Object
22
23
24
|
# File 'lib/yao/resources/old_sample.rb', line 22
def user
@user ||= Yao::User.get(user_id)
end
|