class Dao::Entity::State
Public Class Methods
build_with_attrs(attrs)
click to toggle source
# File lib/dao/entity/state.rb, line 6 def self.build_with_attrs(attrs) state = Class.new(self) state.define_attribute_methods(*attrs) state.send(:attr_accessor, *attrs) attrs.each do |attr| state.send(:define_method, "#{ attr }=") do |val| if public_send(attr) != val attribute_will_change!(attr) instance_variable_set("@#{ attr}", val) end end end state end
new(params={})
click to toggle source
# File lib/dao/entity/state.rb, line 24 def initialize(params={}) assign_attributes(params) changes_applied end
Public Instance Methods
assign_attributes(params)
click to toggle source
# File lib/dao/entity/state.rb, line 29 def assign_attributes(params) params.each do |attr, value| self.public_send("#{attr}=", value) end end
reload!()
click to toggle source
# File lib/dao/entity/state.rb, line 35 def reload! clear_changes_information end
rollback!()
click to toggle source
# File lib/dao/entity/state.rb, line 39 def rollback! restore_attributes end