Commit Graph

23 Commits

Author SHA1 Message Date
Rafael Mendonça França b4cab6a854
Make sure the :if options of callbacks is not mutated
In some cases, the framework was mutating the :if option of callbacks.
Since #38323, those options are frozen, so the framework could raise
exception when trying to mutate those options if they were being resued
with method like `with_options`.
2020-12-29 03:56:54 +00:00
Rafael Mendonça França 0e62667047
Revert "No such class since 8d2866bb80fbe81acb04f5b0c44f152f571fb29f"
This reverts commit dd779c9686.
2019-08-02 00:25:13 -04:00
Akira Matsuda dd779c9686 No such class since 8d2866bb80 2019-08-02 06:21:14 +09:00
Rafael Mendonça França f679933daa
Change the empty block style to have space inside of the block 2018-09-25 13:19:35 -04:00
Daniel Colson 0d50cae996 Use respond_to test helpers 2018-01-25 23:32:58 -05:00
Kir Shatrov d7b1521db8 Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
Matthew Draper 87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590, reversing
changes made to afb66a5a59.
2017-07-02 02:15:17 +09:30
Kir Shatrov cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Rafael Mendonça França 3a25cdca3e
Remove deprecated behavior that halts callbacks when the return is false 2017-02-07 12:19:37 -03:00
Ryuta Kamizono f8d3fed167 Remove deprecated passing string to define callback
And raise `ArgumentError` when passing string to define callback.
2017-02-04 20:48:29 +09:00
Xavier Noria a9dc45459a code gardening: removes redundant selfs
A few have been left for aesthetic reasons, but have made a pass
and removed most of them.

Note that if the method `foo` returns an array, `foo << 1`
is a regular push, nothing to do with assignments, so
no self required.
2016-08-08 01:12:38 +02:00
Xavier Noria b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria 4c20825457 applies new string literal convention in activemodel/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:38:23 +02:00
yui-knk 21f4017fd9 Deprecate passing string to define callback. 2015-12-16 19:56:20 +09:00
claudiob 91b8129320 Deprecate `false` as the way to halt AM callbacks
Before this commit, returning `false` in an ActiveModel `before_` callback
such as `before_create` would halt the callback chain.

After this commit, the behavior is deprecated: will still work until
the next release of Rails but will also display a deprecation warning.

The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
2015-01-02 15:31:56 -08:00
claudiob b7bd7ffa63 Add AM test: after/around callback returning false
This stems from https://github.com/rails/rails/pull/17227#discussion_r21641358

It's simply a clarification of the current behavior by which if an
`after_` or `around_` ActiveModel callback returns +false+, then the callback
chain **is not halted**.

The callback chain in ActiveModel is only halted when a `before_`
callback returns `false`.
2014-12-14 21:20:49 -08:00
Patrick Robertson eebb9ddf9b Convert ActiveModel to 1.9 hash syntax.
I also attempted to fix other styleguide violations such as
{ a: :b } over {a: :b} and foo(b: 'bar') over foo( b: 'bar' ).
2013-05-01 18:01:46 -07:00
Vipul A M 233737706c fix some typos found in activemodel 2013-03-18 17:20:05 +05:30
John Firebaugh 57bc25c5f8 Use run_callbacks; the generated _run_<name>_callbacks method is not a public interface.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-01-31 19:45:53 -02:00
Neeraj Singh 72c1e19c33 after_create in ActiveModel should in the order specified
[#5650 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-27 23:11:31 +02:00
Subba Rao Pasupuleti ef0da581e9 no callbacks should be created for empty array [#5289 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:12:26 -03:00
Neeraj Singh b462952886 Use better assertion methods for testing
[#4645 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-19 10:18:36 +02:00
José Valim 6d390671f6 Move ActiveRecord callbacks implementation to ActiveModel and make use of it.
Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local>
2009-12-28 16:19:23 -08:00