unidom-action 1.3 → 1.4

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: f31dd730a139d63444402e390d90935ff2934dd3
4
- data.tar.gz: 105c820d1fa963af60906abc57b0614d51c44a22
3
+ metadata.gz: 1f54580defbffedb8fcd0cc269390a9d977933fa
4
+ data.tar.gz: 1b65ba248ca4b878ab86dbc8da8f0b5560034ba9
5
5
  SHA512:
6
- metadata.gz: 86c6bbe0c122902a41fd0fedea688573fe247b3776c1dadf115e41e5ac6fdd0e9e67c3e7600b1670ee61e74dc093095ffd4a0aea9cb270b649b4de7d1c994405
7
- data.tar.gz: 70c194d39972a46f018bfad14072d82aceb87efe2aeb7493449b98945aace1cb97b6c32a22c8fc620032583860715096a42ae7d6086809a713081f8a096f96e7
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: 'Time' }
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
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Action
3
- VERSION = '1.3'.freeze
3
+ VERSION = '1.4'.freeze
4
4
  end
5
5
  end
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.3'
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-12 00:00:00.000000000 Z
11
+ date: 2016-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common