unidom-action 1.3 → 1.4
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 +4 -4
- data/README.md +5 -1
- data/app/models/unidom/action/acting.rb +4 -0
- data/app/models/unidom/action/concerns/as_acted.rb +16 -0
- data/lib/unidom/action/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f54580defbffedb8fcd0cc269390a9d977933fa
|
|
4
|
+
data.tar.gz: 1b65ba248ca4b878ab86dbc8da8f0b5560034ba9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b6620724b0412c197b1cf9ff8d2ec5406969a86bf23158ba9e6379221b31c3f8284480f0fac4657a456b5689e7cee7d15063cdd78300bfc50e412e6a4898500
|
|
7
|
+
data.tar.gz: 13b895b8c94cda54846d8d25ab059047faace6be8bf81d78459ecd7a504eb2d289897024048e7983e5e4d31c1027186c71bce201dc9649e8c4103a607246498f
|
data/README.md
CHANGED
|
@@ -43,7 +43,10 @@ user = Unidom::Visitor::User.create!
|
|
|
43
43
|
|
|
44
44
|
# Create/Update/Delete the person
|
|
45
45
|
person = Unidom::Party::Person.create! name: 'Tim'
|
|
46
|
-
acting = Unidom::Action::Acting.create! actor_visitor: user, actor_party: person, reason: reason, acted: person, from_value: {}, thru_value: { name: '
|
|
46
|
+
acting = Unidom::Action::Acting.create! actor_visitor: user, actor_party: person, reason: reason, acted: person, from_value: {}, thru_value: { name: 'Tim' }
|
|
47
|
+
# or the following source code do the exact same thing
|
|
48
|
+
acting = Unidom::Action::Acting.act! person, from: {}, thru: { name: 'Tim' }, due_to: reason, by: person, via: user, at: Time.now, action_code: 'C'
|
|
49
|
+
|
|
47
50
|
actings = Unidom::Action::Acting.acted_via(user).acted_by(person).acted_is(person).caused_by(reason)
|
|
48
51
|
|
|
49
52
|
# Update the state of the person
|
|
@@ -82,6 +85,7 @@ include Unidom::Action::Concerns::AsStateTransitorParty
|
|
|
82
85
|
|
|
83
86
|
The As Acted concern do the following tasks for the includer automatically:
|
|
84
87
|
1. Define the has_many :actings macro as: ``has_many :actings, class_name: 'Unidom::Action::Acting', as: :acted``
|
|
88
|
+
2. Define the #is_acted! method as: ``is_acted!(from: nil, thru: nil, due_to: nil, by: nil, via: nil, at: Time.now, action_code: 'C')``
|
|
85
89
|
|
|
86
90
|
### As Actor Party concern
|
|
87
91
|
|
|
@@ -19,4 +19,8 @@ class Unidom::Action::Acting < Unidom::Action::ApplicationRecord
|
|
|
19
19
|
scope :acted_is, ->(acted) { where acted: acted }
|
|
20
20
|
scope :caused_by, ->(reason) { where reason_id: to_id(reason) }
|
|
21
21
|
|
|
22
|
+
def self.act!(it, from: nil, thru: nil, due_to: nil, by: nil, via: nil, at: Time.now, action_code: 'C')
|
|
23
|
+
create! from_value: from, thru_value: thru, actor_visitor: via, actor_party: by, acted: it, reason: due_to, action_code: action_code, opened_at: at
|
|
24
|
+
end
|
|
25
|
+
|
|
22
26
|
end
|
|
@@ -6,6 +6,22 @@ module Unidom::Action::Concerns::AsActed
|
|
|
6
6
|
|
|
7
7
|
has_many :actings, class_name: 'Unidom::Action::Acting', as: :acted
|
|
8
8
|
|
|
9
|
+
def is_acted!(from: nil, thru: nil, due_to: nil, by: nil, via: nil, at: Time.now, action_code: 'C')
|
|
10
|
+
actings.create! from_value: from, thru_value: thru, actor_visitor: via, actor_party: by, acted: self, reason: due_to, action_code: action_code, opened_at: at
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
=begin
|
|
14
|
+
def is_acted?(due_to: nil, by: nil, via: nil, at: Time.now, action_code: 'C')
|
|
15
|
+
query = actings.acted_is self
|
|
16
|
+
query = query.acted_via via if via.present?
|
|
17
|
+
query = query.acted_by by if by.present?
|
|
18
|
+
query = query.caused_by due_to if due_to.present?
|
|
19
|
+
query = query.action_coded_as action_code if action_code.present?
|
|
20
|
+
query = query.valid_at now: at if at.present?
|
|
21
|
+
query = query.alive.exists?
|
|
22
|
+
end
|
|
23
|
+
=end
|
|
24
|
+
|
|
9
25
|
end
|
|
10
26
|
|
|
11
27
|
module ClassMethods
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unidom-action
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '1.
|
|
4
|
+
version: '1.4'
|
|
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-10-
|
|
11
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: unidom-common
|