Class: Fog::Model
- Inherits:
-
Object
- Object
- Fog::Model
- Extended by:
- Attributes::ClassMethods
- Includes:
- Attributes::InstanceMethods
- Defined in:
- lib/fog/model.rb
Direct Known Subclasses
AWS::Compute::Address, AWS::Compute::Flavor, AWS::Compute::Image, AWS::Compute::KeyPair, AWS::Compute::SecurityGroup, AWS::Compute::Server, AWS::Compute::Snapshot, AWS::Compute::Volume, AWS::Storage::Directory, AWS::Storage::File, Bluebox::Compute::Flavor, Bluebox::Compute::Image, Bluebox::Compute::Server, Local::Storage::Directory, Local::Storage::File, Rackspace::Compute::Flavor, Rackspace::Compute::Image, Rackspace::Compute::Server, Rackspace::Storage::Directory, Rackspace::Storage::File, Slicehost::Compute::Flavor, Slicehost::Compute::Image, Slicehost::Compute::Server, Terremark::Shared::Address, Terremark::Shared::Network, Terremark::Shared::Server, Terremark::Shared::Task, Terremark::Shared::Vdc, Vcloud::Model
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
Instance Method Summary collapse
- #collection ⇒ Object
-
#initialize(new_attributes = {}) ⇒ Model
constructor
A new instance of Model.
- #inspect ⇒ Object
- #reload ⇒ Object
- #to_json ⇒ Object
- #wait_for(timeout = 600, interval = 1, &block) ⇒ Object
Methods included from Attributes::ClassMethods
_load, aliases, attribute, attributes, identity, ignore_attributes, ignored_attributes
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #identity, #identity=, #merge_attributes, #new_record?, #requires
Constructor Details
#initialize(new_attributes = {}) ⇒ Model
Returns a new instance of Model.
13 14 15 |
# File 'lib/fog/model.rb', line 13 def initialize(new_attributes = {}) merge_attributes(new_attributes) end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
7 8 9 |
# File 'lib/fog/model.rb', line 7 def connection @connection end |
Instance Method Details
#collection ⇒ Object
9 10 11 |
# File 'lib/fog/model.rb', line 9 def collection @collection end |
#inspect ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fog/model.rb', line 17 def inspect Thread.current[:formatador] ||= Formatador.new data = "#{Thread.current[:formatador].indentation}<#{self.class.name}" Thread.current[:formatador].indent do unless self.class.attributes.empty? data << "\n#{Thread.current[:formatador].indentation}" data << self.class.attributes.map {|attribute| "#{attribute}=#{send(attribute).inspect}"}.join(",\n#{Thread.current[:formatador].indentation}") end end data << "\n#{Thread.current[:formatador].indentation}>" data end |
#reload ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/fog/model.rb', line 30 def reload if data = collection.get(identity) new_attributes = data.attributes merge_attributes(new_attributes) self end end |
#to_json ⇒ Object
38 39 40 |
# File 'lib/fog/model.rb', line 38 def to_json attributes.to_json end |
#wait_for(timeout = 600, interval = 1, &block) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/fog/model.rb', line 42 def wait_for(timeout=600, interval=1, &block) reload Fog.wait_for(timeout, interval) do reload or raise Fog::Errors::Error.new("Reload failed, #{self.class} #{self.identity} went away.") instance_eval(&block) end end |