2013-06-18 11:29:42 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Vcloudng
|
|
|
|
|
|
|
|
class Organization < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
2013-06-19 11:06:44 -04:00
|
|
|
attribute :name, :aliases => :FullName
|
2013-06-18 11:29:42 -04:00
|
|
|
attribute :type
|
|
|
|
attribute :href
|
2013-06-19 11:06:44 -04:00
|
|
|
attribute :description, :aliases => :Description
|
2013-06-18 12:56:19 -04:00
|
|
|
|
2013-06-18 14:51:12 -04:00
|
|
|
def vdcs
|
|
|
|
requires :id
|
|
|
|
service.vdcs(:organization => self)
|
2013-06-18 12:56:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def catalogs
|
|
|
|
requires :id
|
|
|
|
service.catalogs(:organization => self)
|
|
|
|
end
|
|
|
|
|
2013-06-24 11:04:55 -04:00
|
|
|
def networks
|
|
|
|
requires :id
|
|
|
|
service.networks(:organization => self)
|
|
|
|
end
|
|
|
|
|
2013-07-08 14:13:36 -04:00
|
|
|
def initialize(attrs={})
|
|
|
|
super(attrs)
|
2013-07-09 07:19:14 -04:00
|
|
|
lazy_load_attrs = self.class.attributes - attributes.keys
|
|
|
|
lazy_load_attrs.each do |attr|
|
|
|
|
puts "-#{attr}-"
|
|
|
|
attributes[attr]= NonLoaded if attributes[attr].nil?
|
|
|
|
make_lazy_load_method(attr)
|
|
|
|
end
|
2013-07-08 14:13:36 -04:00
|
|
|
end
|
|
|
|
|
2013-07-09 07:19:14 -04:00
|
|
|
def make_lazy_load_method(attr)
|
|
|
|
self.class.instance_eval do
|
|
|
|
define_method(attr) do
|
|
|
|
reload if attributes[attr] == NonLoaded and !@inspecting
|
|
|
|
attributes[attr]
|
|
|
|
end
|
|
|
|
end
|
2013-07-08 14:13:36 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def inspect
|
|
|
|
@inspecting = true
|
|
|
|
out = super
|
|
|
|
@inspecting = false
|
|
|
|
out
|
|
|
|
end
|
2013-07-09 07:19:14 -04:00
|
|
|
|
2013-07-08 14:13:36 -04:00
|
|
|
|
2013-06-18 11:29:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|