unidom-contact 1.1 → 1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0388ebeaedab50c13f573c893cd2b2760df9860
4
- data.tar.gz: fbec7f5bbbd605149682b1f7aa56a6e5664b8640
3
+ metadata.gz: e1352769a30dacb2e61ede38eb018a7fb88e9511
4
+ data.tar.gz: 0ac784280303119e027fa6c95f45ba0f434e60c7
5
5
  SHA512:
6
- metadata.gz: 484a7df9728f15ee8914fe1765aff14981b01cf684f763d6a99dcb00d51da548fae239bea64c96bb430be5d2bb1ed08fb954b2d801d97152e78b68dee29eb315
7
- data.tar.gz: a6a19549b8c82604038a4552375d2a7cfeeabb33014a4bb7e50f8392cb5969eaee7406d01905510a483902c5f9682cf9bbde0d8ca566536fb97f046c98d23bf4
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
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Contact
3
- VERSION = '1.1'.freeze
3
+ VERSION = '1.2'.freeze
4
4
  end
5
5
  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.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-14 00:00:00.000000000 Z
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