aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorRizwan Reza <rizwanreza@gmail.com>2010-04-02 14:57:30 +0430
committerRizwan Reza <rizwanreza@gmail.com>2010-04-02 14:57:30 +0430
commit0dd3eac967b3dc0225dc4f8b90a3043de54e2fb7 (patch)
treea3a540e38b1e5f6b36f261ae9b2f0116d1f6e39a /activemodel
parent13e3f9c0ce83900d3d5647899a4cff443689c266 (diff)
parent3adaef8ae73a3061a9fe4c5e0256d80bc09b1cf4 (diff)
downloadrails-0dd3eac967b3dc0225dc4f8b90a3043de54e2fb7.tar.gz
rails-0dd3eac967b3dc0225dc4f8b90a3043de54e2fb7.tar.bz2
rails-0dd3eac967b3dc0225dc4f8b90a3043de54e2fb7.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/CHANGELOG17
-rw-r--r--activemodel/activemodel.gemspec25
-rw-r--r--activemodel/lib/active_model/dirty.rb24
-rw-r--r--activemodel/lib/active_model/version.rb2
-rw-r--r--activemodel/test/cases/dirty_test.rb1
5 files changed, 42 insertions, 27 deletions
diff --git a/activemodel/CHANGELOG b/activemodel/CHANGELOG
index eae337e737..8c458b6091 100644
--- a/activemodel/CHANGELOG
+++ b/activemodel/CHANGELOG
@@ -1,4 +1,19 @@
-*Edge*
+*Rails 3.0.0 [beta 2] (April 1st, 2010)*
+
+* #new_record? and #destroyed? were removed from ActiveModel::Lint. Use
+ persisted? instead. A model is persisted if it's not a new_record? and it was
+ not destroyed? [MG]
+
+* Added validations reflection in ActiveModel::Validations [JV]
+
+ Model.validators
+ Model.validators_on(:field)
+
+* #to_key was added to ActiveModel::Lint so we can generate DOM IDs for
+ AMo objects with composite keys [MG]
+
+
+*Rails 3.0.0 [beta 1] (February 4, 2010)*
* ActiveModel::Observer#add_observer!
diff --git a/activemodel/activemodel.gemspec b/activemodel/activemodel.gemspec
index eb9ef7b7c0..9695911398 100644
--- a/activemodel/activemodel.gemspec
+++ b/activemodel/activemodel.gemspec
@@ -1,22 +1,23 @@
-version = File.read(File.expand_path("../../RAILS_VERSION", __FILE__)).strip
+version = File.read(File.expand_path('../../RAILS_VERSION', __FILE__)).strip
Gem::Specification.new do |s|
- s.platform = Gem::Platform::RUBY
- s.name = 'activemodel'
- s.version = version
- s.summary = 'A toolkit for building modeling frameworks (part of Rails).'
+ s.platform = Gem::Platform::RUBY
+ s.name = 'activemodel'
+ s.version = version
+ s.summary = 'A toolkit for building modeling frameworks (part of Rails).'
s.description = 'A toolkit for building modeling frameworks like Active Record and Active Resource. Rich support for attributes, callbacks, validations, observers, serialization, internationalization, and testing.'
+
s.required_ruby_version = '>= 1.8.7'
- s.author = "David Heinemeier Hansson"
- s.email = "david@loudthinking.com"
- s.rubyforge_project = "activemodel"
- s.homepage = "http://www.rubyonrails.org"
+ s.author = 'David Heinemeier Hansson'
+ s.email = 'david@loudthinking.com'
+ s.homepage = 'http://www.rubyonrails.org'
+ s.rubyforge_project = 'activemodel'
+
+ s.files = Dir['CHANGELOG', 'MIT-LICENSE', 'README', 'lib/**/*']
+ s.require_path = 'lib'
s.has_rdoc = true
s.add_dependency('activesupport', version)
-
- s.require_path = 'lib'
- s.files = Dir["CHANGELOG", "MIT-LICENSE", "README", "lib/**/*"]
end
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/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
diff --git a/activemodel/test/cases/dirty_test.rb b/activemodel/test/cases/dirty_test.rb
index 0883363baf..c910cb43d4 100644
--- a/activemodel/test/cases/dirty_test.rb
+++ b/activemodel/test/cases/dirty_test.rb
@@ -6,7 +6,6 @@ class DirtyTest < ActiveModel::TestCase
define_attribute_methods [:name]
def initialize
- super
@name = nil
end