Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8230

Show
Ignore:
Timestamp:
11/28/07 20:12:49 (9 months ago)
Author:
bitsweat
Message:

attr_readonly uses a set of strings instead of an array of symbols internally. References #10300.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/lib/active_record/base.rb

    r8120 r8230  
    673673       # Attributes listed as readonly can be set for a new record, but will be ignored in database updates afterwards. 
    674674       def attr_readonly(*attributes) 
    675          write_inheritable_array("attr_readonly", attributes - (readonly_attributes || [])) 
     675         write_inheritable_attribute("attr_readonly", Set.new(attributes.map(&:to_s)) + (readonly_attributes || [])) 
    676676       end 
    677677 
     
    21042104      def remove_readonly_attributes(attributes) 
    21052105        unless self.class.readonly_attributes.nil? 
    2106           attributes.delete_if { |key, value| self.class.readonly_attributes.include?(key.gsub(/\(.+/,"").intern) } 
     2106          attributes.delete_if { |key, value| self.class.readonly_attributes.include?(key.gsub(/\(.+/,"")) } 
    21072107        else 
    21082108          attributes 
  • trunk/activerecord/test/base_test.rb

    r8142 r8230  
    857857   
    858858  def test_readonly_attributes 
    859     assert_equal [ :title ], ReadonlyTitlePost.readonly_attributes 
     859    assert_equal Set.new([ 'title' ]), ReadonlyTitlePost.readonly_attributes 
    860860     
    861861    post = ReadonlyTitlePost.create(:title => "cannot change this", :body => "changeable") 
  • trunk/activerecord/test/locking_test.rb

    r8156 r8230  
    100100 
    101101  def test_readonly_attributes 
    102     assert_equal [ :first_name ], ReadonlyFirstNamePerson.readonly_attributes 
     102    assert_equal Set.new([ 'first_name' ]), ReadonlyFirstNamePerson.readonly_attributes 
    103103 
    104104    p = ReadonlyFirstNamePerson.create(:first_name => "unchangeable name")