Class: Toaster::StateChange
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Toaster::StateChange
- Defined in:
- lib/toaster/model/state_change.rb
Constant Summary collapse
- ACTION_INSERT =
attr_accessor :property, :action, :value, :old_value, :task_execution
"insert"- ACTION_MODIFY =
"modify"- ACTION_DELETE =
"delete"- ACTION_UNKNOWN =
"unknown"- VALUE_UNKNOWN =
nil
Class Method Summary collapse
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #eql?(obj) ⇒ Boolean
- #hash ⇒ Object
- #initialize1(property = nil, action = nil, value = nil, old_value = nil) ⇒ Object
- #is_delete? ⇒ Boolean
- #is_insert? ⇒ Boolean
- #is_modify? ⇒ Boolean
- #to_s ⇒ Object
Class Method Details
.from_hash_array(prop_change_array) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/toaster/model/state_change.rb', line 48 def self.from_hash_array(prop_change_array) prop_changes = [] prop_change_array.each do |pc| prop_changes << from_hash(pc) end return prop_changes end |
Instance Method Details
#==(obj) ⇒ Object
56 57 58 |
# File 'lib/toaster/model/state_change.rb', line 56 def ==(obj) return eql?(obj) end |
#eql?(obj) ⇒ Boolean
60 61 62 63 64 |
# File 'lib/toaster/model/state_change.rb', line 60 def eql?(obj) return obj.kind_of?(StateChange) && obj.property == @property && obj.action == @action && obj.value == @value && obj.old_value == @old_value end |
#hash ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/toaster/model/state_change.rb', line 66 def hash h = 0 h += @property.hash if @property h += @value.hash if @value h += @action.hash if @action h += @old_value.hash if @old_value return h end |
#initialize1(property = nil, action = nil, value = nil, old_value = nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/toaster/model/state_change.rb', line 19 def initialize1(property=nil, action=nil, value=nil, old_value=nil) @property = property @action = action @value = value @old_value = old_value @task_execution = nil end |
#is_delete? ⇒ Boolean
38 39 40 |
# File 'lib/toaster/model/state_change.rb', line 38 def is_delete?() return action == ACTION_DELETE end |
#is_insert? ⇒ Boolean
44 45 46 |
# File 'lib/toaster/model/state_change.rb', line 44 def is_insert?() return action == ACTION_INSERT end |
#is_modify? ⇒ Boolean
41 42 43 |
# File 'lib/toaster/model/state_change.rb', line 41 def is_modify?() return action == ACTION_MODIFY end |
#to_s ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/toaster/model/state_change.rb', line 27 def to_s if action == ACTION_MODIFY return "Modification of property '#{property}': '#{old_value}' --> '#{value}'" elsif action == ACTION_DELETE return "Deletion of property '#{property}'" elsif action == ACTION_INSERT return "Insertion of property '#{property}': '#{value}'" end return "Action '#{@action}' on property '#{property}', value='#{value}', old_value='#{old_value}'" end |