Class: Yao::Resources::Resource

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

Instance Attribute Summary

Attributes included from RestfullyAccessible

#api_version, #service

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, #get, #list, #list_detail, #resources_path, #resources_path=, #return_single_on_querying=, #update, #with_resources_path

Constructor Details

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

Instance Method Details

#first_sampled_atObject



25
26
27
# File 'lib/yao/resources/resource.rb', line 25

def first_sampled_at
  Time.parse first_sample_timestamp
end

#get_meter(name) ⇒ Object



29
30
31
32
33
# File 'lib/yao/resources/resource.rb', line 29

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

#idObject



9
10
11
# File 'lib/yao/resources/resource.rb', line 9

def id
  resource_id
end

#last_sampled_atObject



21
22
23
# File 'lib/yao/resources/resource.rb', line 21

def last_sampled_at
  Time.parse last_sample_timestamp
end

#metersObject



35
36
37
# File 'lib/yao/resources/resource.rb', line 35

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

#tenantObject



13
14
15
# File 'lib/yao/resources/resource.rb', line 13

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

#userObject



17
18
19
# File 'lib/yao/resources/resource.rb', line 17

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