Class: MemoryModel::Base

Inherits:
Object show all
Extended by:
ActiveModel::Callbacks, ActiveModel::Naming, ActiveModel::Translation, ActiveSupport::Autoload, ConcernedInheritance
Includes:
ActiveModel::Conversion, ActiveModel::MassAssignmentSecurity, ActiveModel::Observing, ActiveModel::Serialization, ActiveModel::Validations, Actionable, Attributable, Collectable, Comparable, Fieldable, Persistence, Versionable
Defined in:
lib/memory_model/base.rb

Defined Under Namespace

Modules: Actionable, Attributable, Collectable, Comparable, Fieldable, Persistence, Versionable

Constant Summary

Constants included from Actionable

Actionable::VALID_IVARS

Instance Method Summary collapse

Methods included from ConcernedInheritance

define_inherited_callback, extended

Methods included from Persistence

#new_record?, #persisted?

Methods included from Versionable

#version, #versions

Methods included from Attributable

#has_attribute?, #inspect, #read_attribute, #write_attribute

Methods included from Actionable

#commit, #deep_dup, #delete, #deleted?, #deleted_at, #destroy, #dup, #freeze, #restore, #save

Methods included from Comparable

#!=, #==, #===

Methods included from Fieldable

#fields

Constructor Details

#initialize(attributes = { }) ⇒ Base

Returns a new instance of Base.



42
43
44
45
46
47
48
49
# File 'lib/memory_model/base.rb', line 42

def initialize(attributes={ })
  unless self.class.collection.is_a? MemoryModel::Collection
    raise MemoryModel::InvalidCollectionError, "#{self.class} does not have an assigned collection"
  end
  @attributes = fields.default_values(self, attributes).with_indifferent_access
  @deleted    = false
  run_callbacks :initialize
end