mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert "Roflscaling!" (for now)
This reverts commit f6b5046305
.
Fear not, the roflscale will return when I have a bit more time and
figure out a better way to do it. (In particular, a way that doesn't
break the build.)
This commit is contained in:
parent
0306f82e0c
commit
9acb340e88
2 changed files with 11 additions and 8 deletions
|
@ -31,9 +31,9 @@ module ActiveRecord
|
||||||
if attr_name == primary_key && attr_name != 'id'
|
if attr_name == primary_key && attr_name != 'id'
|
||||||
generated_attribute_methods.send(:alias_method, :id, primary_key)
|
generated_attribute_methods.send(:alias_method, :id, primary_key)
|
||||||
generated_attribute_methods.module_eval <<-CODE, __FILE__, __LINE__
|
generated_attribute_methods.module_eval <<-CODE, __FILE__, __LINE__
|
||||||
def self.id(v, attributes, attributes_cache, attr_name)
|
def self.attribute_id(v, attributes, attributes_cache, attr_name)
|
||||||
attr_name = '#{primary_key}'
|
attr_name = '#{primary_key}'
|
||||||
send(attr_name, attributes[attr_name], attributes, attributes_cache, attr_name)
|
send(:'attribute_#{attr_name}', attributes[attr_name], attributes, attributes_cache, attr_name)
|
||||||
end
|
end
|
||||||
CODE
|
CODE
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,9 +30,11 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def undefine_attribute_methods
|
def undefine_attribute_methods
|
||||||
if base_class == self && attribute_methods_generated?
|
if base_class == self
|
||||||
column_names.each do |name|
|
generated_attribute_methods.module_eval do
|
||||||
generated_attribute_methods.singleton_class.send(:undef_method, name)
|
public_methods(false).each do |m|
|
||||||
|
singleton_class.send(:undef_method, m) if m.to_s =~ /^attribute_/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ module ActiveRecord
|
||||||
def __temp__(v, attributes, attributes_cache, attr_name)
|
def __temp__(v, attributes, attributes_cache, attr_name)
|
||||||
#{external}
|
#{external}
|
||||||
end
|
end
|
||||||
alias_method '#{attr_name}', :__temp__
|
alias_method 'attribute_#{attr_name}', :__temp__
|
||||||
undef_method :__temp__
|
undef_method :__temp__
|
||||||
STR
|
STR
|
||||||
end
|
end
|
||||||
|
@ -108,11 +110,12 @@ module ActiveRecord
|
||||||
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
|
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
|
||||||
def read_attribute(attr_name)
|
def read_attribute(attr_name)
|
||||||
attr_name = attr_name.to_s
|
attr_name = attr_name.to_s
|
||||||
|
accessor = "attribute_#{attr_name}"
|
||||||
methods = self.class.generated_attribute_methods
|
methods = self.class.generated_attribute_methods
|
||||||
|
|
||||||
if methods.respond_to?(attr_name)
|
if methods.respond_to?(accessor)
|
||||||
if @attributes.has_key?(attr_name) || attr_name == 'id'
|
if @attributes.has_key?(attr_name) || attr_name == 'id'
|
||||||
methods.send(attr_name, @attributes[attr_name], @attributes, @attributes_cache, attr_name)
|
methods.send(accessor, @attributes[attr_name], @attributes, @attributes_cache, attr_name)
|
||||||
end
|
end
|
||||||
elsif !self.class.attribute_methods_generated?
|
elsif !self.class.attribute_methods_generated?
|
||||||
# If we haven't generated the caster methods yet, do that and
|
# If we haven't generated the caster methods yet, do that and
|
||||||
|
|
Loading…
Reference in a new issue