mirror of
				https://github.com/fog/fog.git
				synced 2022-11-09 13:51:43 -05:00 
			
		
		
		
	working _dump/_load, make connection/connection= public
This commit is contained in:
		
							parent
							
								
									ce2ae970e9
								
							
						
					
					
						commit
						9e87d99a17
					
				
					 2 changed files with 32 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -1,6 +1,10 @@
 | 
			
		|||
module Fog
 | 
			
		||||
  class Collection < Array
 | 
			
		||||
 | 
			
		||||
    def self._load(marhsalled)
 | 
			
		||||
      new(Marshal.load(marshalled))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def self.attribute(name, other_names = [])
 | 
			
		||||
      class_eval <<-EOS, __FILE__, __LINE__
 | 
			
		||||
        attr_accessor :#{name}
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +28,10 @@ module Fog
 | 
			
		|||
      @attributes ||= []
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def _dump
 | 
			
		||||
      Marshal.dump(attributes)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def attributes
 | 
			
		||||
      attributes = {}
 | 
			
		||||
      for attribute in self.class.attributes
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +40,14 @@ module Fog
 | 
			
		|||
      attributes
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def connection=(new_connection)
 | 
			
		||||
      @connection = new_connection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def connection
 | 
			
		||||
      @connection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def create(attributes = {})
 | 
			
		||||
      object = new(attributes)
 | 
			
		||||
      object.save
 | 
			
		||||
| 
						 | 
				
			
			@ -85,14 +101,6 @@ module Fog
 | 
			
		|||
 | 
			
		||||
    private
 | 
			
		||||
 | 
			
		||||
    def connection=(new_connection)
 | 
			
		||||
      @connection = new_connection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def connection
 | 
			
		||||
      @connection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def remap_attributes(attributes, mapping)
 | 
			
		||||
      for key, value in mapping
 | 
			
		||||
        if attributes.key?(key)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,10 @@
 | 
			
		|||
module Fog
 | 
			
		||||
  class Model
 | 
			
		||||
 | 
			
		||||
    def self._load(marshalled)
 | 
			
		||||
      new(Marshal.load(marshalled))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def self.attribute(name, other_names = [])
 | 
			
		||||
      class_eval <<-EOS, __FILE__, __LINE__
 | 
			
		||||
        attr_accessor :#{name}
 | 
			
		||||
| 
						 | 
				
			
			@ -25,6 +29,10 @@ module Fog
 | 
			
		|||
      @attributes ||= []
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def _dump
 | 
			
		||||
      Marshal.dump(attributes)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def attributes
 | 
			
		||||
      attributes = {}
 | 
			
		||||
      for attribute in self.class.attributes
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +45,14 @@ module Fog
 | 
			
		|||
      @collection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def connection=(new_connection)
 | 
			
		||||
      @connection = new_connection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def connection
 | 
			
		||||
      @connection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def identity
 | 
			
		||||
      send(self.class.instance_variable_get('@identity'))
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -79,14 +95,6 @@ module Fog
 | 
			
		|||
      @collection = new_collection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def connection=(new_connection)
 | 
			
		||||
      @connection = new_connection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def connection
 | 
			
		||||
      @connection
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def remap_attributes(attributes, mapping)
 | 
			
		||||
      for key, value in mapping
 | 
			
		||||
        if attributes.key?(key)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue