active_record-events 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Njk0YzdlMmY0YzRiMmYxNzdjMmE3OTMyODUwNjIzNjgwZmEzOTZiMg==
4
+ ZTljYzhjZWM1OGRmODA4YjIzYjYyYzMwMDg3YmMxOWVmMWM5ZTMwOA==
5
5
  data.tar.gz: !binary |-
6
- NDNiMmViY2U5NTNmZmY5ZjQ3NzdkMTY5Mjg4YTlmMTJmMTI3NjI3Yw==
6
+ ZDljYzhkYTk1ZjI1ZjIyNWRlYmZmZTVhNDIzNDNhNjFiNmRlZjA5Ng==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTlhYzQ1ODkwNjg1ZjNkYjhjZTY3ZTgwZWIyYjgxYTgzNDM1NmJlNmExODEy
10
- ZTU1MTYxOTllMDAwNmUwOTM0MTVkM2FlODZlN2ZjNzViOTYzNmFmOTk2NTEw
11
- Y2JlNzEzZGUyN2EyMTk4M2Q2YWZiNTQ2ODI5NjAzYWY1ZWMwNjY=
9
+ Nzg4ODRhMzRiNzFiMjUwZjkzNWNiNTFmZmE5MjAzZDZjNGE1YzkzNmI5MWQx
10
+ NDVhZjJlOGM2YzNlNGFhZjc2ZjgzNzMwN2Y1YzU5MjVmOTU3OTMyMzJjY2Zl
11
+ Y2NiZDU1ZTk4M2UxYjdlOTRjNzM1ZTUwZjMwMjQ0Njk1MWMzOTk=
12
12
  data.tar.gz: !binary |-
13
- YWZmMzdhYjNmODJlMmY5ZDExOGE1ODBjNmQ3NTc4YTJmOWZlMjIwODU0ZTMz
14
- MmJiZjU1ZTJlYjQyOWI4NDA3N2U2NzZjYWFkNDAxNTIyYTE0MDEyMWExOWQz
15
- YTA0MmE4MGQzNzNjMWQwNjQzZGQzMzJmZTE3YzBmNDBjMzdlMDg=
13
+ ODYzYjIyZTNjM2I2NDNhNTk0YWFmOTkxZGU4NjQwZjQ1YzdjODJjM2M4OTkz
14
+ YzUzZjZmMWM4ZWVhZTNmYWEwYzZkZjA0YzFjNDZhY2Q5MDVhOTk2ODk1ODA3
15
+ NjE2ZmI5NzdiYzcxN2IyOTFiNjU3NWJkNTA3OWFmYjIxMWMyNzY=
data/README.md CHANGED
@@ -69,14 +69,14 @@ scope :not_completed, -> { where(completed_at: nil) }
69
69
  scope :completed, -> { where.not(completed_at: nil) }
70
70
  ```
71
71
 
72
- ### Subject
72
+ ### Object
73
73
 
74
74
  There are events which do not relate to a model itself but to one of its attributes – take the `User` model with the `email_confirmed_at` field as an example.
75
- In order to keep method names grammatically correct, you can specify a subject using the `subject` option.
75
+ In order to keep method names grammatically correct, you can specify an object using the `object` option.
76
76
 
77
77
  ```ruby
78
78
  class User < ActiveRecord::Base
79
- has_event :confirm, subject: :email
79
+ has_event :confirm, object: :email
80
80
  end
81
81
  ```
82
82
 
@@ -5,34 +5,33 @@ module ActiveRecord
5
5
  class Naming
6
6
  def initialize(infinitive, options = {})
7
7
  @infinitive = infinitive
8
- @subject = options[:subject].presence
8
+ @object = options[:object].presence
9
9
  end
10
10
 
11
11
  def field
12
- [@subject, past_participle, 'at'].compact.join('_')
12
+ [@object, past_participle, 'at'].compact.join('_')
13
13
  end
14
14
 
15
15
  def predicate
16
- [@subject, past_participle].compact.join('_')
16
+ [@object, past_participle].compact.join('_')
17
17
  end
18
18
 
19
19
  def action
20
- [@infinitive, @subject].compact.join('_')
20
+ [@infinitive, @object].compact.join('_')
21
21
  end
22
22
 
23
23
  def scope
24
- [@subject, past_participle].compact.join('_')
24
+ [@object, past_participle].compact.join('_')
25
25
  end
26
26
 
27
27
  def inverse_scope
28
- [@subject, 'not', past_participle].compact.join('_')
28
+ [@object, 'not', past_participle].compact.join('_')
29
29
  end
30
30
 
31
31
  private
32
32
 
33
33
  def past_participle
34
- options = { tense: :past, aspect: :perfective }
35
- @infinitive.verb.conjugate(options)
34
+ @infinitive.verb.conjugate(tense: :past, aspect: :perfective)
36
35
  end
37
36
  end
38
37
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Events
3
- VERSION = '1.1.0'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe ActiveRecord::Events::Naming do
4
- context 'without a subject' do
4
+ context 'without an object' do
5
5
  subject { described_class.new(:complete) }
6
6
 
7
7
  it 'generates a field name' do
@@ -25,8 +25,8 @@ RSpec.describe ActiveRecord::Events::Naming do
25
25
  end
26
26
  end
27
27
 
28
- context 'with a subject' do
29
- subject { described_class.new(:confirm, subject: :email) }
28
+ context 'with an object' do
29
+ subject { described_class.new(:confirm, object: :email) }
30
30
 
31
31
  it 'generates a field name' do
32
32
  expect(subject.field).to eq('email_confirmed_at')
@@ -31,7 +31,7 @@ RSpec.describe ActiveRecord::Events do
31
31
 
32
32
  let(:user) { create(:user) }
33
33
 
34
- it 'handles a subject' do
34
+ it 'handles an object' do
35
35
  user.confirm_email
36
36
  expect(user.email_confirmed?).to be(true)
37
37
  end
@@ -1,3 +1,3 @@
1
1
  class User < ActiveRecord::Base
2
- has_event :confirm, subject: :email
2
+ has_event :confirm, object: :email
3
3
  end
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-events
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartosz Pieńkowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-06 00:00:00.000000000 Z
11
+ date: 2017-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord