提交 b55f5a3e 编写于 作者: R Ryuta Kamizono

Extract `readonly_attribute?`

上级 a1c269fb
......@@ -437,7 +437,7 @@ def attributes_with_values(attribute_names)
def attributes_for_update(attribute_names)
attribute_names &= self.class.column_names
attribute_names.delete_if do |name|
readonly_attribute?(name)
self.class.readonly_attribute?(name)
end
end
......@@ -460,10 +460,6 @@ def format_for_inspect(value)
end
end
def readonly_attribute?(name)
self.class.readonly_attributes.include?(name)
end
def pk_attribute?(name)
name == @primary_key
end
......
......@@ -939,7 +939,7 @@ def _create_record(attribute_names = self.attribute_names)
end
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
def _raise_record_not_destroyed
......
......@@ -19,6 +19,10 @@ def attr_readonly(*attributes)
def readonly_attributes
_attr_readonly
end
def readonly_attribute?(name) # :nodoc:
_attr_readonly.include?(name)
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册