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, #update_attribute, #update_attributes, #write_attribute

Instance Attribute Details

#new_recordObject Also known as: persisted?, new_record?

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



20
21
22
# File 'lib/dynamoid/document.rb', line 20

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

#initialize(attrs = {}) ⇒ Object



14
15
16
17
18
# File 'lib/dynamoid/document.rb', line 14

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