Class: Yao::Resources::Resource

Inherits:
Base
  • Object
show all
Includes:
TenantAssociationable
Defined in:
lib/yao/resources/resource.rb

Instance Attribute Summary

Attributes included from RestfullyAccessible

#service

Instance Method Summary collapse

Methods included from TenantAssociationable

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

Methods included from RestfullyAccessible

#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

Constructor Details

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

Instance Method Details

#first_sampled_atObject



23
24
25
# File 'lib/yao/resources/resource.rb', line 23

def first_sampled_at
  Time.parse first_sample_timestamp
end

#get_meter(name) ⇒ Object



27
28
29
30
31
# File 'lib/yao/resources/resource.rb', line 27

def get_meter(name)
  if link = links.find{|l| l["rel"] == name }
    Yao::Sample.list(link["href"])
  end
end

#idObject



11
12
13
# File 'lib/yao/resources/resource.rb', line 11

def id
  resource_id
end

#last_sampled_atObject



19
20
21
# File 'lib/yao/resources/resource.rb', line 19

def last_sampled_at
  Time.parse last_sample_timestamp
end

#metersObject



33
34
35
# File 'lib/yao/resources/resource.rb', line 33

def meters
  links.map{|l| l["rel"] }.delete_if{|n| n == 'self' }
end

#userObject



15
16
17
# File 'lib/yao/resources/resource.rb', line 15

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