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::EC2::Address, AWS::EC2::Flavor, AWS::EC2::Image, AWS::EC2::KeyPair, AWS::EC2::SecurityGroup, AWS::EC2::Server, AWS::EC2::Snapshot, AWS::EC2::Volume, AWS::S3::Directory, AWS::S3::File, Bluebox::Flavor, Bluebox::Image, Bluebox::Server, Local::Directory, Local::File, Rackspace::Files::Directory, Rackspace::Files::File, Rackspace::Servers::Flavor, Rackspace::Servers::Image, Rackspace::Servers::Server, Slicehost::Flavor, Slicehost::Image, Slicehost::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, &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 |