unidom-contact 1.0.1 → 1.1

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: c6b52e9476d9a77414af8b68e149f4ee51bca82d
4
- data.tar.gz: 6a45b3f8cbbf67f58b0cb012f3e6578b2ff910ab
3
+ metadata.gz: a0388ebeaedab50c13f573c893cd2b2760df9860
4
+ data.tar.gz: fbec7f5bbbd605149682b1f7aa56a6e5664b8640
5
5
  SHA512:
6
- metadata.gz: 6237d0b6602ae8c1510f9ca86fe3e7596ccbad30fedc9c39584225c99b4a14c1228f7a4a9530b8020ac90a0fa4df51647a7842d992299573cd4e7b64f4deb595
7
- data.tar.gz: 82f2ed78eea723e731cb054795367fbdcba58ac76305007512870ab58815e39ba4a72297d0172962d6b4e3378d0d1cecab5d45777a8c5790ef8dd1b7b9444ba4
6
+ metadata.gz: 484a7df9728f15ee8914fe1765aff14981b01cf684f763d6a99dcb00d51da548fae239bea64c96bb430be5d2bb1ed08fb954b2d801d97152e78b68dee29eb315
7
+ data.tar.gz: a6a19549b8c82604038a4552375d2a7cfeeabb33014a4bb7e50f8392cb5969eaee7406d01905510a483902c5f9682cf9bbde0d8ca566536fb97f046c98d23bf4
data/README.md CHANGED
@@ -40,3 +40,17 @@ Unidom::Contact::EmailAddress.full_address_is('topbit.du@gmail.com').first
40
40
  # Find the Email Address
41
41
 
42
42
  ```
43
+
44
+ ## Include the Concerns
45
+ ```ruby
46
+ include Unidom::Contact::Concerns::AsContact
47
+ include Unidom::Contact::Concerns::AsSubscriber
48
+ ```
49
+
50
+ ### As Contact concern
51
+ The As Contact concern do the following tasks for the includer automatically:
52
+ 1. Define the has_many :contact_subscriptions macro as: ``has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :contact``
53
+
54
+ ### As Subscriber concern
55
+ The As Subscriber concern do the following tasks for the includer automatically:
56
+ 1. Define the has_many :contact_subscriptions macro as: ``has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :subscriber``
@@ -0,0 +1,11 @@
1
+ module Unidom::Contact::Concerns::AsContact
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :contact
8
+
9
+ end
10
+
11
+ end
@@ -0,0 +1,11 @@
1
+ module Unidom::Contact::Concerns::AsSubscriber
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :subscriber
8
+
9
+ end
10
+
11
+ end
@@ -4,19 +4,18 @@ class Unidom::Contact::EmailAddress < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'unidom_email_addresses'
6
6
 
7
+ include Unidom::Common::Concerns::ModelExtension
8
+ include Unidom::Contact::Concerns::AsContact
9
+
7
10
  validates :personalized_name, presence: true, length: { in: 1..self.columns_hash['personalized_name'].limit }
8
11
  validates :full_address, presence: true, length: { in: 4..self.columns_hash['full_address'].limit }, uniqueness: true
9
12
  validates :local_part, presence: true, length: { in: 1..self.columns_hash['local_part'].limit }
10
13
  validates :domain_part, presence: true, length: { in: 2..self.columns_hash['domain_part'].limit }
11
14
 
12
- has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :contact
13
-
14
15
  scope :full_address_is, ->(full_address) { where full_address: full_address }
15
16
  scope :local_part_is, ->(local_part) { where local_part: local_part }
16
17
  scope :domain_part_is, ->(domain_part) { where domain_part: domain_part }
17
18
 
18
- include Unidom::Common::Concerns::ModelExtension
19
-
20
19
  before_validation do
21
20
  self.full_address.strip!
22
21
  self.personalized_name = self.full_address if self.personalized_name.blank?
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Contact
3
- VERSION = '1.0.1'.freeze
3
+ VERSION = '1.1'.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.0.1
4
+ version: '1.1'
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-12 00:00:00.000000000 Z
11
+ date: 2016-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -40,6 +40,8 @@ files:
40
40
  - app/assets/stylesheets/unidom/contact/application.css
41
41
  - app/controllers/unidom/contact/application_controller.rb
42
42
  - app/helpers/unidom/contact/application_helper.rb
43
+ - app/models/unidom/contact/concerns/as_contact.rb
44
+ - app/models/unidom/contact/concerns/as_subscriber.rb
43
45
  - app/models/unidom/contact/contact_subscription.rb
44
46
  - app/models/unidom/contact/email_address.rb
45
47
  - app/views/layouts/unidom/contact/application.html.erb