mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Extract readonly_attribute?
This commit is contained in:
parent
a1c269fbdf
commit
b55f5a3ed9
3 changed files with 6 additions and 6 deletions
|
@ -437,7 +437,7 @@ module ActiveRecord
|
||||||
def attributes_for_update(attribute_names)
|
def attributes_for_update(attribute_names)
|
||||||
attribute_names &= self.class.column_names
|
attribute_names &= self.class.column_names
|
||||||
attribute_names.delete_if do |name|
|
attribute_names.delete_if do |name|
|
||||||
readonly_attribute?(name)
|
self.class.readonly_attribute?(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -460,10 +460,6 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def readonly_attribute?(name)
|
|
||||||
self.class.readonly_attributes.include?(name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pk_attribute?(name)
|
def pk_attribute?(name)
|
||||||
name == @primary_key
|
name == @primary_key
|
||||||
end
|
end
|
||||||
|
|
|
@ -939,7 +939,7 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def verify_readonly_attribute(name)
|
def verify_readonly_attribute(name)
|
||||||
raise ActiveRecordError, "#{name} is marked as readonly" if self.class.readonly_attributes.include?(name)
|
raise ActiveRecordError, "#{name} is marked as readonly" if self.class.readonly_attribute?(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def _raise_record_not_destroyed
|
def _raise_record_not_destroyed
|
||||||
|
|
|
@ -19,6 +19,10 @@ module ActiveRecord
|
||||||
def readonly_attributes
|
def readonly_attributes
|
||||||
_attr_readonly
|
_attr_readonly
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def readonly_attribute?(name) # :nodoc:
|
||||||
|
_attr_readonly.include?(name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue