Module: Sandthorn::AggregateRoot::DirtyHashy

Includes:
Base
Defined in:
lib/sandthorn/aggregate_root_dirty_hashy.rb

Instance Attribute Summary

Attributes included from Base

#aggregate_current_event_version, #aggregate_events, #aggregate_id, #aggregate_originating_version, #aggregate_stored_serialized_object

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#aggregate_base_initialize, #aggregate_trace, #all, #commit, #save

Class Method Details

.included(base) ⇒ Object



9
10
11
# File 'lib/sandthorn/aggregate_root_dirty_hashy.rb', line 9

def self.included(base)
  base.extend(Sandthorn::AggregateRoot::Base::ClassMethods)
end

Instance Method Details

#aggregate_initializeObject



13
14
15
# File 'lib/sandthorn/aggregate_root_dirty_hashy.rb', line 13

def aggregate_initialize
  @hashy = ::DirtyHashy.new
end

#get_deltaObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/sandthorn/aggregate_root_dirty_hashy.rb', line 17

def get_delta
  extract_relevant_aggregate_instance_variables.each do |var|
    @hashy[var.to_s.delete("@")] = self.instance_variable_get("#{var}")
  end
  aggregate_attribute_deltas = []
  @hashy.changes.each do |attribute|
    aggregate_attribute_deltas << { :attribute_name => attribute[0], :old_value => attribute[1][0], :new_value => attribute[1][1]}
  end
  aggregate_attribute_deltas
end