Sha256: fa8d1ce77cd75a561b539c9c29770602c0369bdcc8fc16c54c52c8d195a15978

Contents?: true

Size: 723 Bytes

Versions: 6

Compression:

Stored size: 723 Bytes

Contents

# encoding: utf-8
module Dynamoid #:nodoc:

  module Attributes
    extend ActiveSupport::Concern
    
    attr_accessor :attributes
    alias :raw_attributes :attributes
      
    def write_attribute(name, value)
      attributes[name.to_sym] = value
    end
    alias :[]= :write_attribute
    
    def read_attribute(name)
      attributes[name.to_sym]
    end
    alias :[] :read_attribute
    
    def update_attributes(attributes)
      self.attributes = attributes
      save
    end
    
    def update_attribute(attribute, value)
      self.attributes[attribute] = value
      save
    end
    
    module ClassMethods
      def attributes
        [self.fields + [:id]].flatten.uniq
      end
    end
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dynamoid-0.0.7 lib/dynamoid/attributes.rb
dynamoid-0.0.6 lib/dynamoid/attributes.rb
dynamoid-0.0.5 lib/dynamoid/attributes.rb
dynamoid-0.0.4 lib/dynamoid/attributes.rb
dynamoid-0.0.3 lib/dynamoid/attributes.rb
dynamoid-0.0.2 lib/dynamoid/attributes.rb