Skip to content

Commit

Permalink
Improve wording of comments
Browse files Browse the repository at this point in the history
Most of the time, these methods are called from actual methods defined
from columns in the schema, not from method_missing, so the current
wording is misleading.
  • Loading branch information
shioyama committed Apr 13, 2019
1 parent bdcdb2b commit c9d7517
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion activemodel/lib/active_model/attributes.rb
Expand Up @@ -91,7 +91,7 @@ def attribute(attr_name)
@attributes.fetch_value(name)
end

# Handle *= for method_missing.
# Dispatch target for <tt>*=</tt> attribute methods.
def attribute=(attribute_name, value)
write_attribute(attribute_name, value)
end
Expand Down
14 changes: 7 additions & 7 deletions activemodel/lib/active_model/dirty.rb
Expand Up @@ -165,17 +165,17 @@ def changed
mutations_from_database.changed_attribute_names
end

# Handles <tt>*_changed?</tt> for +method_missing+.
# Dispatch target for <tt>*_changed?</tt> attribute methods.
def attribute_changed?(attr_name, **options) # :nodoc:
mutations_from_database.changed?(attr_name.to_s, options)
end

# Handles <tt>*_was</tt> for +method_missing+.
# Dispatch target for <tt>*_was</tt> attribute methods.
def attribute_was(attr_name) # :nodoc:
mutations_from_database.original_value(attr_name.to_s)
end

# Handles <tt>*_previously_changed?</tt> for +method_missing+.
# Dispatch target for <tt>*_previously_changed?</tt> attribute methods.
def attribute_previously_changed?(attr_name) # :nodoc:
mutations_before_last_save.changed?(attr_name.to_s)
end
Expand Down Expand Up @@ -253,22 +253,22 @@ def mutations_before_last_save
@mutations_before_last_save ||= ActiveModel::NullMutationTracker.instance
end

# Handles <tt>*_change</tt> for +method_missing+.
# Dispatch target for <tt>*_change</tt> attribute methods.
def attribute_change(attr_name)
mutations_from_database.change_to_attribute(attr_name.to_s)
end

# Handles <tt>*_previous_change</tt> for +method_missing+.
# Dispatch target for <tt>*_previous_change</tt> attribute methods.
def attribute_previous_change(attr_name)
mutations_before_last_save.change_to_attribute(attr_name.to_s)
end

# Handles <tt>*_will_change!</tt> for +method_missing+.
# Dispatch target for <tt>*_will_change!</tt> attribute methods.
def attribute_will_change!(attr_name)
mutations_from_database.force_change(attr_name.to_s)
end

# Handles <tt>restore_*!</tt> for +method_missing+.
# Dispatch target for <tt>restore_*!</tt> attribute methods.
def restore_attribute!(attr_name)
attr_name = attr_name.to_s
if attribute_changed?(attr_name)
Expand Down
Expand Up @@ -65,7 +65,7 @@ def attributes_before_type_cast

private

# Handle *_before_type_cast for method_missing.
# Dispatch target for <tt>*_before_type_cast</tt> attribute methods.
def attribute_before_type_cast(attribute_name)
read_attribute_before_type_cast(attribute_name)
end
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/attribute_methods/query.rb
Expand Up @@ -32,7 +32,7 @@ def query_attribute(attr_name)
end

private
# Handle *? for method_missing.
# Dispatch target for <tt>*?</tt> attribute methods.
def attribute?(attribute_name)
query_attribute(attribute_name)
end
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/attribute_methods/write.rb
Expand Up @@ -58,7 +58,7 @@ def write_attribute_without_type_cast(attr_name, value)
value
end

# Handle *= for method_missing.
# Dispatch target for <tt>*=</tt> attribute methods.
def attribute=(attribute_name, value)
_write_attribute(attribute_name, value)
end
Expand Down

0 comments on commit c9d7517

Please sign in to comment.