Sha256: 7d021aebcbca82191d05cfd90e1a2d41a9d0b3eee2ffd10d4feca9eed89d15a3

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

module StorageRoom
  module Attributes
    def initialize(attributes={})     
      self.attributes = attributes
    end
    
    def set_from_api(attributes)
      reset!
      
      self.attributes = attributes
    end
        
    def [](name)
      self.attributes[name]
    end
    
    def []=(name, value)
      self.attributes[name] = value
    end
    
    def attributes
      @attributes ||= Hash.new.with_indifferent_access
    end
    
    def attributes=(hash = {})
      hash.each do |k, v|
        self.attributes[k] = v
      end
    end
    
    def reset!
      @attributes = Hash.new.with_indifferent_access
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
storage_room-0.1.0 lib/storage_room/attributes.rb