From 0f67f00d94aca0b65856a4305792997c6a34fff9 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Sun, 1 Feb 2015 13:43:35 +0530 Subject: AM#Dirty doc fixes - Grammar fixes - Add doc for changes_include? - implemntations => implementations --- activemodel/lib/active_model/dirty.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb index afba9bab0d..24999c1a5c 100644 --- a/activemodel/lib/active_model/dirty.rb +++ b/activemodel/lib/active_model/dirty.rb @@ -118,7 +118,7 @@ module ActiveModel attribute_method_affix prefix: 'restore_', suffix: '!' end - # Returns +true+ if any attribute have unsaved changes, +false+ otherwise. + # Returns +true+ if any of the attributes have unsaved changes, +false+ otherwise. # # person.changed? # => false # person.name = 'bob' @@ -166,7 +166,7 @@ module ActiveModel @changed_attributes ||= ActiveSupport::HashWithIndifferentAccess.new end - # Handle *_changed? for +method_missing+. + # Handles *_changed? for +method_missing+. def attribute_changed?(attr, options = {}) #:nodoc: result = changes_include?(attr) result &&= options[:to] == __send__(attr) if options.key?(:to) @@ -174,7 +174,7 @@ module ActiveModel result end - # Handle *_was for +method_missing+. + # Handles *_was for +method_missing+. def attribute_was(attr) # :nodoc: attribute_changed?(attr) ? changed_attributes[attr] : __send__(attr) end @@ -186,6 +186,7 @@ module ActiveModel private + # Returns +true+ if attr_name is changed, +false+ otherwise. def changes_include?(attr_name) attributes_changed_by_setter.include?(attr_name) end @@ -196,18 +197,18 @@ module ActiveModel @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new end - # Clear all dirty data: current changes and previous changes. + # Clears all dirty data: current changes and previous changes. def clear_changes_information # :doc: @previously_changed = ActiveSupport::HashWithIndifferentAccess.new @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new end - # Handle *_change for +method_missing+. + # Handles *_change for +method_missing+. def attribute_change(attr) [changed_attributes[attr], __send__(attr)] if attribute_changed?(attr) end - # Handle *_will_change! for +method_missing+. + # Handles *_will_change! for +method_missing+. def attribute_will_change!(attr) return if attribute_changed?(attr) @@ -220,7 +221,7 @@ module ActiveModel set_attribute_was(attr, value) end - # Handle restore_*! for +method_missing+. + # Handles restore_*! for +method_missing+. def restore_attribute!(attr) if attribute_changed?(attr) __send__("#{attr}=", changed_attributes[attr]) @@ -229,7 +230,7 @@ module ActiveModel end # This is necessary because `changed_attributes` might be overridden in - # other implemntations (e.g. in `ActiveRecord`) + # other implementations (e.g. in `ActiveRecord`) alias_method :attributes_changed_by_setter, :changed_attributes # :nodoc: # Force an attribute to have a particular "before" value -- cgit v1.2.3