unidom-contact 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -5
- data/app/controllers/unidom/contact/application_controller.rb +3 -0
- data/app/jobs/unidom/contact/application_job.rb +3 -0
- data/app/mailers/unidom/contact/application_mailer.rb +3 -0
- data/app/models/unidom/contact/application_record.rb +3 -0
- data/app/models/unidom/contact/concerns/as_contact.rb +6 -0
- data/app/models/unidom/contact/concerns/as_email_address_subscriber.rb +3 -0
- data/app/models/unidom/contact/concerns/as_subscriber.rb +6 -0
- data/app/models/unidom/contact/contact_subscription.rb +8 -1
- data/app/models/unidom/contact/email_address.rb +1 -1
- data/lib/unidom/contact/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a31840fd34a0bb826bedc37522434d55e1b1892
|
4
|
+
data.tar.gz: 5b6e045f09fd6f10fed5181e7b959114facadc8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2897744add33c91dcad01c36795676e0608369c58a2d4e889afedd09b531a2e1e35f978a9a4211c715a814887c3bd2d2791048d14540346023c1ecb40289ca69
|
7
|
+
data.tar.gz: ea63341ffc55c8d7dececc2527cfe922e694608041342216d3c27f1c71f7d83f415d8e59ea1e7cc2425679348362e5f136a29479cfc0d86f0951ea1ba00b7ff2
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Unidom Contact 联系方式领域模型引擎
|
2
2
|
|
3
|
+
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/unidom-contact/frames)
|
3
4
|
[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
|
5
|
+
|
4
6
|
[![Gem Version](https://badge.fury.io/rb/unidom-contact.svg)](https://badge.fury.io/rb/unidom-contact)
|
5
7
|
[![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-contact.svg)](https://gemnasium.com/github.com/topbitdu/unidom-contact)
|
6
8
|
|
@@ -67,19 +69,43 @@ include Unidom::Contact::Concerns::AsEmailAddressSubscriber
|
|
67
69
|
### As Contact concern
|
68
70
|
|
69
71
|
The As Contact concern do the following tasks for the includer automatically:
|
70
|
-
|
71
|
-
|
72
|
+
|
73
|
+
1. Define the has_many :contact_subscriptions macro as: ``has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :contact``
|
74
|
+
|
75
|
+
2. Define the #is_subscribed_as_contact! method as: ``is_subscribed_as_contact!(by: nil, at: Time.now, name: by.try(:name), primary: true)``
|
76
|
+
|
72
77
|
3. Define the #is_subscribed_as_contact? method as: ``is_subscribed_as_contact?(by: nil, at: Time.now, primary: true)``
|
73
78
|
|
74
79
|
### As Subscriber concern
|
75
80
|
|
76
81
|
The As Subscriber concern do the following tasks for the includer automatically:
|
77
|
-
|
78
|
-
|
82
|
+
|
83
|
+
1. Define the has_many :contact_subscriptions macro as: ``has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :subscriber``
|
84
|
+
|
85
|
+
2. Define the #subscribe_contact! method as: ``subscribe_contact!(contact, at: Time.now, name: nil, primary: true)``
|
86
|
+
|
79
87
|
3. Define the #subscribe_contact? method as: ``subscribe_contact?(contact, at: Time.now, primary: true)``
|
80
88
|
|
81
89
|
### As Email Address Subscriber concern
|
82
90
|
|
83
91
|
The As Email Address Subscriber concern do the following tasks for the includer automatically:
|
84
|
-
|
92
|
+
|
93
|
+
1. Include the As Subscriber concern
|
94
|
+
|
85
95
|
2. Define the has_many :email_addresses macro as: ``has_many :email_addresses, through: :contact_subscriptions, source: :contact, source_type: 'Unidom::Contact::EmailAddress'``
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
## Disable the Model & Migration
|
100
|
+
|
101
|
+
If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
|
102
|
+
```ruby
|
103
|
+
# config/initializers/unidom.rb
|
104
|
+
Unidom::Common.configure do |options|
|
105
|
+
|
106
|
+
options[:neglected_namespaces] = %w{
|
107
|
+
Unidom::Contact
|
108
|
+
}
|
109
|
+
|
110
|
+
end
|
111
|
+
```
|
@@ -1,3 +1,6 @@
|
|
1
|
+
##
|
2
|
+
# As Contact 是联系方式的领域逻辑关注点。
|
3
|
+
|
1
4
|
module Unidom::Contact::Concerns::AsContact
|
2
5
|
|
3
6
|
extend ActiveSupport::Concern
|
@@ -6,6 +9,9 @@ module Unidom::Contact::Concerns::AsContact
|
|
6
9
|
|
7
10
|
has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :contact
|
8
11
|
|
12
|
+
##
|
13
|
+
# 将当前联系方式与指定的参与者 by 关联起来。 at 是关联时间,缺省为当前时间。 name 是联系方式的备注。 primary 是主要联系标志。
|
14
|
+
# 如: phone_number.is_subscribed_as_contact! by: current_person, at: Time.now, name: '私人手机号码', primary: true
|
9
15
|
def is_subscribed_as_contact!(by: nil, at: Time.now, name: by.try(:name), primary: true)
|
10
16
|
|
11
17
|
raise ArgumentError.new('The by argument is required.') if by.blank?
|
@@ -1,3 +1,6 @@
|
|
1
|
+
##
|
2
|
+
# As Subscriber 是联系人的领域逻辑关注点。
|
3
|
+
|
1
4
|
module Unidom::Contact::Concerns::AsSubscriber
|
2
5
|
|
3
6
|
extend ActiveSupport::Concern
|
@@ -6,6 +9,9 @@ module Unidom::Contact::Concerns::AsSubscriber
|
|
6
9
|
|
7
10
|
has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :subscriber
|
8
11
|
|
12
|
+
##
|
13
|
+
# 将当前参与者与指定的联系方式 contact 关联起来。 at 是关联时间,缺省为当前时间。 name 是联系方式的备注。 primary 是主要联系标志。
|
14
|
+
# 如: current_person.subscribe_contact! phone_number, at: Time.now, name: '私人手机号码', primary: true
|
9
15
|
def subscribe_contact!(contact, at: Time.now, name: nil, primary: true)
|
10
16
|
|
11
17
|
raise ArgumentError.new('The contact argument is required.') if contact.blank?
|
@@ -17,8 +17,15 @@ class Unidom::Contact::ContactSubscription < Unidom::Contact::ApplicationRecord
|
|
17
17
|
scope :contact_is, ->(contact) { where contact: contact }
|
18
18
|
scope :subscribed_by, ->(subscriber) { where subscriber: subscriber }
|
19
19
|
|
20
|
+
##
|
21
|
+
# 将联系方式 contact 和订阅者 subscriber 关联起来。
|
22
|
+
# name 是关联的名称,主要用于备注作用,缺省为订阅者的 name 。
|
23
|
+
# primary 是主要联系方式标志,缺省为 true 。
|
24
|
+
# grade 是评分,缺省为 0 。 priority 是优先级,缺省为 0 。
|
25
|
+
# opened_at 是生效时间。
|
26
|
+
# 如: Unidom::Contact::ContactSubscription.subscribe! contact: phone_number, subscriber: selected_person
|
20
27
|
def self.subscribe!(contact: nil, subscriber: nil, name: subscriber.try(:name), primary: true, grade: 0, priority: 0, opened_at: Time.now)
|
21
28
|
contact_is(contact).subscribed_by(subscriber).valid_at(now: opened_at).alive.first_or_create! name: name, elemental: primary, grade: grade, priority: priority, opened_at: opened_at
|
22
29
|
end
|
23
30
|
|
24
|
-
end
|
31
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Contact::ContactSubscription'
|
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.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.9'
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
28
28
|
The Contact domain model engine includes Contact Subscription and Email Address
|
29
29
|
models. Unidom (统一领域对象模型)是一系列的领域模型引擎。联系方式领域模型引擎包括联系方式订阅和电子邮箱地址的模型。
|