Changeset 8824
- Timestamp:
- 02/08/08 23:35:33 (5 months ago)
- Files:
-
- trunk/activerecord/lib/active_record/base.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/lib/active_record/base.rb
r8806 r8824 2213 2213 2214 2214 2215 # Returns a hash of all the attributes with their names as keys and clones of their objects as values.2215 # Returns a hash of all the attributes with their names as keys and the values of the attributes as values. 2216 2216 def attributes(options = nil) 2217 attributes = clone_attributes :read_attribute 2217 attrs = {} 2218 self.attribute_names.each do |name| 2219 attrs[name]=read_attribute(name) 2220 end 2218 2221 2219 2222 if options.nil? 2220 attr ibutes2223 attrs 2221 2224 else 2222 2225 if except = options[:except] 2223 2226 except = Array(except).collect { |attribute| attribute.to_s } 2224 except.each { |attribute_name| attr ibutes.delete(attribute_name) }2225 attr ibutes2227 except.each { |attribute_name| attrs.delete(attribute_name) } 2228 attrs 2226 2229 elsif only = options[:only] 2227 2230 only = Array(only).collect { |attribute| attribute.to_s } 2228 attr ibutes.delete_if { |key, value| !only.include?(key) }2229 attr ibutes2231 attrs.delete_if { |key, value| !only.include?(key) } 2232 attrs 2230 2233 else 2231 2234 raise ArgumentError, "Options does not specify :except or :only (#{options.keys.inspect})"