Changeset 5416
- Timestamp:
- 11/02/06 20:20:46 (2 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/base.rb (modified) (2 diffs)
- trunk/activerecord/test/base_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r5405 r5416 1 1 *SVN* 2 3 * Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes] 2 4 3 5 * Deprecation: object transactions warning. [Jeremy Kemper] trunk/activerecord/lib/active_record/base.rb
r5359 r5416 1875 1875 def define_read_methods 1876 1876 self.class.columns_hash.each do |name, column| 1877 unless self.class.serialized_attributes[name] 1878 define_read_method(name.to_sym, name, column) unless respond_to_without_attributes?(name) 1879 define_question_method(name) unless respond_to_without_attributes?("#{name}?") 1877 unless respond_to_without_attributes?(name) 1878 if self.class.serialized_attributes[name] 1879 define_read_method_for_serialized_attribute(name) 1880 else 1881 define_read_method(name.to_sym, name, column) 1882 end 1883 end 1884 1885 unless respond_to_without_attributes?("#{name}?") 1886 define_question_method(name) 1880 1887 end 1881 1888 end … … 1895 1902 end 1896 1903 1904 # Define read method for serialized attribute. 1905 def define_read_method_for_serialized_attribute(attr_name) 1906 unless attr_name.to_s == self.class.primary_key.to_s 1907 self.class.read_methods << attr_name 1908 end 1909 1910 evaluate_read_method attr_name, "def #{attr_name}; unserialize_attribute('#{attr_name}'); end" 1911 end 1912 1897 1913 # Define an attribute ? method. 1898 1914 def define_question_method(attr_name) trunk/activerecord/test/base_test.rb
r5256 r5416 1477 1477 private 1478 1478 def assert_readers(model, exceptions) 1479 expected_readers = Set.new(model.column_names - (model.serialized_attributes.keys + ['id']))1479 expected_readers = Set.new(model.column_names - ['id']) 1480 1480 expected_readers += expected_readers.map { |col| "#{col}?" } 1481 1481 expected_readers -= exceptions