Module: Dynamoid::Document

Extended by:
ActiveSupport::Concern
Includes:
Components
Defined in:
lib/dynamoid/document.rb

Overview

This is the base module for all domain objects that need to be persisted to the database as documents.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Attributes included from Attributes

#attributes

Instance Method Summary collapse

Methods included from Persistence

#save

Methods included from Indexes

#key_for_index, #save_indexes

Methods included from Attributes

#read_attribute, #write_attribute

Instance Attribute Details

#new_recordObject

Returns the value of attribute new_record.



10
11
12
# File 'lib/dynamoid/document.rb', line 10

def new_record
  @new_record
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
# File 'lib/dynamoid/document.rb', line 18

def ==(other)
  other.respond_to?(:id) && other.id == self.id
end

#initialize(attrs = {}) ⇒ Object



12
13
14
15
16
# File 'lib/dynamoid/document.rb', line 12

def initialize(attrs = {})
  @new_record = true
  @attributes ||= {}
  self.class.attributes.each {|att| write_attribute(att, attrs[att])}
end