Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Class
- def attr_accessor_with_history(attr_name)
- attr_name = attr_name.to_s
- attr_reader attr_name
- attr_reader attr_name+"_history"
- class_eval %Q{
- def #{attr_name}=(new_value)
- @#{attr_name}_history ||= []
- @#{attr_name}_history << @#{attr_name}
- @#{attr_name} = new_value
- end
- }
- end
- end
Add Comment
Please, Sign In to add comment