# File lib/fog/vcloud_director/compute.rb, line 304 def inspect @inspecting = true out = super @inspecting = false out end
# File lib/fog/vcloud_director/compute.rb, line 281 def lazy_load_attrs @lazy_load_attrs ||= self.class.attributes - attributes.keys end
it adds an attr_loaded? method to know if the value has been loaded yet or not: ie description_loaded?
# File lib/fog/vcloud_director/compute.rb, line 296 def make_attr_loaded_method(attr) self.class.instance_eval do define_method("#{attr}_loaded?") do attributes[attr] != NonLoaded end end end
# File lib/fog/vcloud_director/compute.rb, line 285 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 end
# File lib/fog/vcloud_director/compute.rb, line 272 def initialize(attrs={}) super(attrs) lazy_load_attrs.each do |attr| attributes[attr]= NonLoaded if attributes[attr].nil? make_lazy_load_method(attr) end self.class.attributes.each {|attr| make_attr_loaded_method(attr)} end