lib/dynamoid/document.rb in dynamoid-1.3.3 vs lib/dynamoid/document.rb in dynamoid-1.3.4
- old
+ new
@@ -6,11 +6,11 @@
module Document
extend ActiveSupport::Concern
include Dynamoid::Components
included do
- class_attribute :options, :read_only_attributes, :base_class
+ class_attribute :options, :read_only_attributes, :base_class, instance_accessor: false
self.options = {}
self.read_only_attributes = []
self.base_class = self
Dynamoid.included_models << self unless Dynamoid.included_models.include? self
@@ -118,9 +118,13 @@
#
# @return [Dynamoid::Document] the new document
#
# @since 0.2.0
def initialize(attrs = {})
+ # we need this hack for Rails 4.0 only
+ # because `run_callbacks` calls `attributes` getter while it is still nil
+ @attributes = {}
+
run_callbacks :initialize do
@new_record = true
@attributes ||= {}
@associations ||= {}