unidom-contact 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1352769a30dacb2e61ede38eb018a7fb88e9511
|
4
|
+
data.tar.gz: 0ac784280303119e027fa6c95f45ba0f434e60c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73d7215db5354e4e43658c0c269e5ef18ac04fbb1aa4a87e8717e7290429d47d94b450719e4247b7c5cbe57f4df6207e190522b422f6f28dce8575076ef2a5bb
|
7
|
+
data.tar.gz: 79d399cbd561687621903b1d341ae4f504039e05e0b5f2790bc5c44d8ca7df45e8e22204a84c730a39892ddcd041e2e856c6113ff87a79c9ec075ae7ffe50524
|
data/README.md
CHANGED
@@ -45,12 +45,20 @@ Unidom::Contact::EmailAddress.full_address_is('topbit.du@gmail.com').first
|
|
45
45
|
```ruby
|
46
46
|
include Unidom::Contact::Concerns::AsContact
|
47
47
|
include Unidom::Contact::Concerns::AsSubscriber
|
48
|
+
include Unidom::Contact::Concerns::AsEmailAddressSubscriber
|
48
49
|
```
|
49
50
|
|
50
51
|
### As Contact concern
|
51
|
-
The As Contact concern do the following tasks for the includer automatically:
|
52
|
+
The As Contact concern do the following tasks for the includer automatically:
|
52
53
|
1. Define the has_many :contact_subscriptions macro as: ``has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :contact``
|
54
|
+
2. Define the #subscribe_contact! method as: ``def subscribe_contact!(contact, at: Time.now)``
|
53
55
|
|
54
56
|
### As Subscriber concern
|
55
|
-
The As Subscriber concern do the following tasks for the includer automatically:
|
57
|
+
The As Subscriber concern do the following tasks for the includer automatically:
|
56
58
|
1. Define the has_many :contact_subscriptions macro as: ``has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :subscriber``
|
59
|
+
2. Define the #is_subscribed_as_contact! method as: ``def is_subscribed_as_contact!(by: nil, at: Time.now)``
|
60
|
+
|
61
|
+
### As Email Address Subscriber concern
|
62
|
+
The As Email Address Subscriber concern do the following tasks for the includer automatically:
|
63
|
+
1. Include the As Subscriber concern
|
64
|
+
2. Define the has_many :email_addresses macro as: ``has_many :email_addresses, through: :contact_subscriptions, source: :contact, source_type: 'Unidom::Contact::EmailAddress'``
|
@@ -6,6 +6,15 @@ module Unidom::Contact::Concerns::AsContact
|
|
6
6
|
|
7
7
|
has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :contact
|
8
8
|
|
9
|
+
def is_subscribed_as_contact!(by: nil, at: Time.now, name: by.try(:name))
|
10
|
+
|
11
|
+
raise ArgumentError.new('The by argument is required.') if by.blank?
|
12
|
+
raise ArgumentError.new('The at argument is required.') if at.blank?
|
13
|
+
|
14
|
+
contact_subscriptions.create! subscriber: by, opened_at: at, name: name
|
15
|
+
|
16
|
+
end
|
17
|
+
|
9
18
|
end
|
10
19
|
|
11
20
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Unidom::Contact::Concerns::AsEmailAddressSubscriber
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
include Unidom::Contact::Concerns::AsSubscriber
|
6
|
+
|
7
|
+
included do |includer|
|
8
|
+
|
9
|
+
has_many :email_addresses, through: :contact_subscriptions, source: :contact, source_type: 'Unidom::Contact::EmailAddress'
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -6,6 +6,15 @@ module Unidom::Contact::Concerns::AsSubscriber
|
|
6
6
|
|
7
7
|
has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :subscriber
|
8
8
|
|
9
|
+
def subscribe_contact!(contact, at: Time.now, name: nil)
|
10
|
+
|
11
|
+
raise ArgumentError.new('The contact argument is required.') if contact.blank?
|
12
|
+
raise ArgumentError.new('The at argument is required.' ) if at.blank?
|
13
|
+
|
14
|
+
contact_subscriptions.create! contact: contact, opened_at: at, name: name||self.name
|
15
|
+
|
16
|
+
end
|
17
|
+
|
9
18
|
end
|
10
19
|
|
11
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-contact
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- app/controllers/unidom/contact/application_controller.rb
|
42
42
|
- app/helpers/unidom/contact/application_helper.rb
|
43
43
|
- app/models/unidom/contact/concerns/as_contact.rb
|
44
|
+
- app/models/unidom/contact/concerns/as_email_address_subscriber.rb
|
44
45
|
- app/models/unidom/contact/concerns/as_subscriber.rb
|
45
46
|
- app/models/unidom/contact/contact_subscription.rb
|
46
47
|
- app/models/unidom/contact/email_address.rb
|