Changeset 4632
- Timestamp:
- 07/31/06 03:43:03 (2 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record.rb (modified) (2 diffs)
- trunk/activerecord/lib/active_record/attribute_methods.rb (added)
- trunk/activerecord/lib/active_record/base.rb (modified) (4 diffs)
- trunk/activerecord/test/attribute_methods_test.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r4626 r4632 1 1 *SVN* 2 3 * Factor the attribute#{suffix} methods out of method_missing for easier extension. [Jeremy Kemper] 2 4 3 5 * Patch sql injection vulnerability when using integer or float columns. [Jamis Buck] trunk/activerecord/lib/active_record.rb
r4462 r4632 53 53 require 'active_record/calculations' 54 54 require 'active_record/xml_serialization' 55 require 'active_record/attribute_methods' 55 56 56 57 ActiveRecord::Base.class_eval do … … 70 71 include ActiveRecord::Calculations 71 72 include ActiveRecord::XmlSerialization 73 include ActiveRecord::AttributeMethods 72 74 end 73 75 trunk/activerecord/lib/active_record/base.rb
r4604 r4632 1672 1672 def respond_to?(method, include_priv = false) 1673 1673 if @attributes.nil? 1674 return super 1674 return super 1675 1675 elsif attr_name = self.class.column_methods_hash[method.to_sym] 1676 1676 return true if @attributes.include?(attr_name) || attr_name == self.class.primary_key … … 1678 1678 elsif @attributes.include?(method_name = method.to_s) 1679 1679 return true 1680 elsif md = /(=|\?|_before_type_cast)$/.match(method_name)1680 elsif md = self.class.match_attribute_method?(method.to_s) 1681 1681 return true if @attributes.include?(md.pre_match) 1682 1682 end … … 1750 1750 end 1751 1751 end 1752 1752 1753 1753 1754 # Allows access to the object attributes, which are held in the @attributes hash, as were … … 1768 1769 elsif self.class.primary_key.to_s == method_name 1769 1770 id 1770 elsif md = /(=|_before_type_cast)$/.match(method_name)1771 elsif md = self.class.match_attribute_method?(method_name) 1771 1772 attribute_name, method_type = md.pre_match, md.to_s 1772 1773 if @attributes.include?(attribute_name) 1773 case method_type 1774 when '=' 1775 write_attribute(attribute_name, args.first) 1776 when '_before_type_cast' 1777 read_attribute_before_type_cast(attribute_name) 1778 end 1774 __send__("attribute#{method_type}", attribute_name, *args, &block) 1779 1775 else 1780 1776 super