unidom-action 0.7 → 1.0

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: ab217d868ee6c7a3254a098fb76b2dc0fc597a3a
4
- data.tar.gz: e12993e9c20532f8186e7f25c4f145ecd8cdf3e2
3
+ metadata.gz: 3471b684f908d9fbc84708e8ae0a07b687fd9716
4
+ data.tar.gz: b8fa0235ba1e59ce7d1c68c5900763aacff46013
5
5
  SHA512:
6
- metadata.gz: fe8228fd8880c33bb7e2ef4c19e04a4e0ce8186356015274e72c86af7afb7ffaa33fd7e258264816cf531f709a840b2a985e4c8d694f5e72653e712374057ab9
7
- data.tar.gz: 4b5f4f838d9ee6fca69dac42bb8fd7d2d221493744786103caffec9bb00bb7703efa7a7189c7bc8ba51a702aa1258ee11dd5fc1b884388cf16a8e79f4502d277
6
+ metadata.gz: 6123fd18b1db0fa66a3241569d8b19412d801cf25b2b8696f2711b78a77a6b8272c5ff44cf07ac1494dc9dab6e22f58aad05992f073a2adf10491a1fec74eb44
7
+ data.tar.gz: cf160b984f506f2aeec2322187f3e85e335ea9468d40fef556f2a7b9d5139999920fb413fe5745827b86aca5f4f07dac6d2ba18d96664e92c2ea8bf3db32abbc
data/README.md CHANGED
@@ -48,11 +48,19 @@ acting = Unidom::Action::Acting.create! actor_visitor: user, actor_party: person
48
48
  # Update the state of the person
49
49
  person.state = 'R'
50
50
  person.save!
51
+ # Create a state transition to record the above change
51
52
  transition = Unidom::Action::StateTransition.create! transitor_visitor: user, transitor_party: person, reason: reason, subject: person, from_state: 'C', thru_state: 'R'
53
+ # The following source code also create a state transition to record the above change
54
+ transition = Unidom::Action::StateTransition.transit! transitor_visitor: user, transitor_party: person, reason: reason, subject: person, from_state: 'C', thru_state: 'R', opened_at: Time.now
55
+ # The reason could be nil.
52
56
 
53
57
  # Soft destroy the person
54
58
  person.soft_destroy
55
- obsolescence = Unidom::Action::Obsolescence.create! obsolescer_visitor: user, obsolescer_party: person, reason: reason, obsolesced: person
59
+ # Create an obsolescing to record the above change
60
+ obsolescence = Unidom::Action::Obsolescing.create! obsolescer_visitor: user, obsolescer_party: person, reason: reason, obsolesced: person, obsolescence_code: 'OBSL'
61
+ # The following source code also create an obsolescing to record the above change
62
+ obsolescence = Unidom::Action::Obsolescing.obsolesce! obsolesced: person, obsolescer_visitor: user, obsolescer_party: person, reason: reason, obsolescence_code: 'OBSL', opened_at: Time.now
63
+
56
64
  # The reason could be nil.
57
65
  ```
58
66
 
@@ -14,4 +14,8 @@ class Unidom::Action::Obsolescing < Unidom::Action::ApplicationRecord
14
14
  belongs_to :obsolesced, polymorphic: true
15
15
  belongs_to :reason, class_name: 'Unidom::Action::Reason'
16
16
 
17
+ def self.obsolesce!(obsolesced: nil, obsolescer_visitor: nil, obsolescer_party: nil, reason: nil, obsolescence_code: 'OBSL', opened_at: Time.now)
18
+ create! obsolesced: obsolesced, obsolescer_visitor: obsolescer_visitor, obsolescer_party: obsolescer_party, reason: reason, obsolescence_code: obsolescence_code, opened_at: opened_at
19
+ end
20
+
17
21
  end
@@ -13,4 +13,8 @@ class Unidom::Action::StateTransition < Unidom::Action::ApplicationRecord
13
13
  belongs_to :subject, polymorphic: true
14
14
  belongs_to :reason, class_name: 'Unidom::Action::Reason'
15
15
 
16
+ def self.transit!(subject: nil, from_state: nil, thru_state: nil, transitor_visitor: nil, transitor_party: nil, reason: nil, opened_at: Time.now)
17
+ create! transitor_visitor: transitor_visitor, transitor_party: transitor_party, subject: subject, reason: reason, from_state: from_state, thru_state: thru_state, opened_at: opened_at
18
+ end
19
+
16
20
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Action
3
- VERSION = '0.7'.freeze
3
+ VERSION = '1.0'.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: '0.7'
4
+ version: '1.0'
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-06 00:00:00.000000000 Z
11
+ date: 2016-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common