aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-04-04 17:34:23 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2010-04-04 17:34:23 +0100
commit00884a59013a658082dab41da5ff41add31b8c43 (patch)
tree666b862b08b04c7a3727ee22b2cd1a2561af4e52 /activemodel/lib
parent48b2451142355b22de5f8130b3debdd4e53e2ba2 (diff)
parent7d7e0627a0490b6b4ddb0ee5429264ccd46f1245 (diff)
downloadrails-00884a59013a658082dab41da5ff41add31b8c43.tar.gz
rails-00884a59013a658082dab41da5ff41add31b8c43.tar.bz2
rails-00884a59013a658082dab41da5ff41add31b8c43.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/dirty.rb24
-rw-r--r--activemodel/lib/active_model/errors.rb2
-rw-r--r--activemodel/lib/active_model/version.rb2
3 files changed, 15 insertions, 13 deletions
diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb
index 2d5acdfced..a7ee15a7f6 100644
--- a/activemodel/lib/active_model/dirty.rb
+++ b/activemodel/lib/active_model/dirty.rb
@@ -91,17 +91,12 @@ module ActiveModel
attribute_method_affix :prefix => 'reset_', :suffix => '!'
end
- def initialize(*)
- @changed_attributes = {}
- super
- end
-
# Do any attributes have unsaved changes?
# person.changed? # => false
# person.name = 'bob'
# person.changed? # => true
def changed?
- !@changed_attributes.empty?
+ !changed_attributes.empty?
end
# List of attributes with unsaved changes.
@@ -109,7 +104,7 @@ module ActiveModel
# person.name = 'bob'
# person.changed # => ['name']
def changed
- @changed_attributes.keys
+ changed_attributes.keys
end
# Map of changed attrs => [original value, new value].
@@ -130,19 +125,24 @@ module ActiveModel
end
private
+ # Map of change <tt>attr => original value</tt>.
+ def changed_attributes
+ @changed_attributes ||= {}
+ end
+
# Handle <tt>*_changed?</tt> for +method_missing+.
def attribute_changed?(attr)
- @changed_attributes.include?(attr)
+ changed_attributes.include?(attr)
end
# Handle <tt>*_change</tt> for +method_missing+.
def attribute_change(attr)
- [@changed_attributes[attr], __send__(attr)] if attribute_changed?(attr)
+ [changed_attributes[attr], __send__(attr)] if attribute_changed?(attr)
end
# Handle <tt>*_was</tt> for +method_missing+.
def attribute_was(attr)
- attribute_changed?(attr) ? @changed_attributes[attr] : __send__(attr)
+ attribute_changed?(attr) ? changed_attributes[attr] : __send__(attr)
end
# Handle <tt>*_will_change!</tt> for +method_missing+.
@@ -153,12 +153,12 @@ module ActiveModel
rescue TypeError, NoMethodError
end
- @changed_attributes[attr] = value
+ changed_attributes[attr] = value
end
# Handle <tt>reset_*!</tt> for +method_missing+.
def reset_attribute!(attr)
- __send__("#{attr}=", @changed_attributes[attr]) if attribute_changed?(attr)
+ __send__("#{attr}=", changed_attributes[attr]) if attribute_changed?(attr)
end
end
end
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 8d28040c32..64b28f6def 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/object/blank'
diff --git a/activemodel/lib/active_model/version.rb b/activemodel/lib/active_model/version.rb
index 85d0eed180..a33657626f 100644
--- a/activemodel/lib/active_model/version.rb
+++ b/activemodel/lib/active_model/version.rb
@@ -3,7 +3,7 @@ module ActiveModel
MAJOR = 3
MINOR = 0
TINY = 0
- BUILD = "beta1"
+ BUILD = "beta2"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end