| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
`ActiveModel::Dirty#[attr_name]_previous_change` to improve access
to recorded changes after the model has been saved.
It makes the dirty-attributes query methods consistent before and after
saving.
|
|\ |
|
| |
| |
| |
| |
| |
| | |
- Grammar fixes
- Add doc for changes_include?
- implemntations => implementations
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The existing example seems somewhat forced: is it realistic
to have a model that accepts state in its initializer but
considers it has not been changed? By allowing state changes
to happen only via accessors it seems more natural that new
instances are considered to be unchanged (as they are in AR).
[ci skip]
|
| | |
|
| | |
|
| |
| |
| |
| | |
As per Rails general coding conventions. Related to #18794 [ci skip]
|
| |
| |
| |
| |
| |
| |
| | |
is wrong.
Added simple initialize and made use of Person.new instead of Person.find_by to clarify the docs.
[ci skip]
|
|/
|
|
|
|
|
|
|
|
|
| |
When an attribute is assigned, we determine if it was already marked as
changed so we can determine if we need to clear the changes, or mark it
as changed. Since this only affects the `attributes_changed_by_setter`
hash, in-place changes are irrelevant to this process. Since calculating
in-place changes can be expensive, we can just skip it here.
I also added a test for the only edge case I could think of that would
be affected by this change.
|
|
|
|
| |
These requires were added only to change deprecation message
|
|
|
|
| |
`ActiveModel::Dirty#reset_changes`.
|
|\ |
|
| |
| |
| |
| |
| |
| |
| | |
Also prevents the word "Model" from linking to the documentation
of ActiveModel::Model because that's not intended.
[ci skip]
|
|/
|
|
|
|
|
|
|
| |
Calling `changed_attributes` will ultimately check if every mutable
attribute has changed in place. Since this gets called whenever an
attribute is assigned, it's extremely slow. Instead, we can avoid this
calculation until we actually need it.
Fixes #18029
|
|
|
|
|
|
| |
since 'attr_name_will_change!' is not an actual method it should
be clearer that you have to insert the attribute name as in line 104
[ci skip]
|
|
|
|
|
|
|
|
|
| |
ActiveModel::Dirty#clear_attribute_changes method
In Rails 4.2 it is impossible to define a custom default value for a model's
attribute without making it appear as _changed?, especially when the model
is first initialized. Making this method publicly visible will allow such a behaviour,
without the need to use private APIs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch uniformizes warning messages. I used the most common style
already present in the code base:
* Capitalize the first word.
* End the message with a full stop.
* "Rails 5" instead of "Rails 5.0".
* Backticks for method names and inline code.
Also, converted a few long strings into the new heredoc convention.
|
|
|
|
|
|
|
| |
WARNING: don't use them! They might change or go away between future beta/RC/
patch releases!
Also added a CHANGELOG entry for this.
|
| |
|
|
|
|
|
|
|
| |
Also make it accept a list of attributes to be changed. This will make
possible to restore only a subset of the changed attributes.
Closes #16203
|
|
|
|
|
|
|
|
|
| |
These methods may cause confusion with the `reset_changes` that
behaves differently
of them.
Also rename undo_changes to restore_changes to match this new set of
methods.
|
|
|
|
|
|
|
|
|
| |
#clear_changes_information
This method name is causing confusion with the `reset_#{attribute}`
methods. While `reset_name` set the value of the name attribute for the
previous value the `reset_changes` only discard the changes and previous
changes.
|
|
|
|
| |
To avoid overload with database rollback
|
| |
|
|\
| |
| |
| | |
Added rollback method to ActiveModel::Dirty
|
| | |
|
| | |
|
|/
|
|
|
|
|
| |
Leave the note for `ActiveModel`, since it can't yet detect mutations
(hopefully we can change this in time for 4.2). However, we now detect
mutations on all supported types in `ActiveRecord`, so we can note that
`_will_change!` is no longer needed there.
|
| |
|
|
|
|
|
|
|
| |
Before this patch after the changes are applied the changes can be only
accessed using string keys, but before symbols are also accepted.
After this change every state of the model will be consistent.
|
|
|
|
| |
model.name_changed?(from: "Pete", to: "Ringo")
|
|
|
|
|
|
| |
These methods were made "public" in 47617ecd so that `method_missing`
can invoke them without going through `send`, but they aren't meant
for consumption from outside of Rails.
|
|\
| |
| |
| |
| |
| |
| | |
Updated DirtyModel's @changed_attributes hash to be symbol/string agnostic
Conflicts:
activemodel/CHANGELOG.md
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
of an instance. When using the attribute_will_change! method, you must
supply a string and not a symbol or the *_changed? method will break
(because it is looking for the attribute name as a string in the keys
of the underlying hash). To remedy this, I simply made the underlying
hash a HashWithIndifferentAccess so it won't matter if you supply
the attribute name as a symbol or string to attribute_will_change!.
|
| |
| |
| |
| |
| |
| | |
It is reload! in the class definition.
[ci skip]
|
| |
| |
| |
| | |
[ci skip]
|
| |
| |
| |
| | |
Make AM::Dirty less dirty to plugin into AR or other library
|
| | |
|
| |
| |
| |
| |
| | |
I also attempted to fix other styleguide violations such as
{ a: :b } over {a: :b} and foo(b: 'bar') over foo( b: 'bar' ).
|
| | |
|
| |
| |
| |
| |
| | |
This reverts commit 637a7d9d357a0f3f725b0548282ca8c5e7d4af4a, reversing
changes made to 5937bd02dee112646469848d7fe8a8bfcef5b4c1.
|
|/ |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
When resetting an attribute, you expect it to return to the state it was
before any changes. Namely, this fixes this unexpected behavior:
~~~ruby
model.name = "Bob"
model.reset_name!
model.name_changed? #=> true
~~~
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|