activerecord-fsm 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: b281902b922a683073baf632654a0657f7e9bdbb3c3348960491432428a68444
4
- data.tar.gz: 157d440eb10fd597a283e677c6f698c2cf5b76e3888599a0d26d960678132eca
3
+ metadata.gz: 351276a49e27c515507b1e7857e9a67f554014b0d104f3044b7564ef3c8f1b60
4
+ data.tar.gz: b6820092158ca95745e4d4286539b1bb3a2b89995a639415a753cb2815bfedad
5
5
  SHA512:
6
- metadata.gz: 696e9bc135f6c6b755102e5fb535a941bebf6d9e1fd224312673b889bb9ee1628b7551aa1cc939fc520b9570f9eff8495aa7470b3946e87dcbb2a2a5595c1524
7
- data.tar.gz: e9d4c60a0d9eed133867c619bdf4558cdbb31766f225c3d892f55f5a76ed2eb691f745c8ae7b468d1aa91b0e9cb4001cf634788735acb5bd918ceaa6e8690a30
6
+ metadata.gz: 16bb26cfdd1bea69b4f740e575b7d7c3319e1acce307650fdc999ae1dea86b9477d07b9e3352ec61e7abc13a3b6e688a7ce9f9c7435e691901c5f2cba05c4d25
7
+ data.tar.gz: ac6f2bd60084ac177923c03afa8934d90cc7a12709c77b402237f6f3b8e8a19699cbdbdcffaf5af643c6bca95fdfcfc7e70828ccec03dfb2cf2e992d35bbfb6b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-fsm (0.1.1)
4
+ activerecord-fsm (0.1.2)
5
5
  activerecord (>= 5.2, < 7.0)
6
6
  activesupport (>= 5.2, < 7.0)
7
7
 
data/README.md CHANGED
@@ -42,15 +42,25 @@ Maybe you need to do migration, add one column named `status`:
42
42
  end
43
43
  end
44
44
  ```
45
- **Model without using `fsm_define` will only act as the same with `NomalModel` which doesn't has fsm mechanic.**
46
- In other words, using `fsm_define` will make `NomalModel` become `FsmModel`.
45
+ **Model without using `fsm_define` will only act as the same with `NormalModel` which doesn't has fsm mechanic.**
46
+ In other words, using `fsm_define` will make `NormalModel` become `FsmModel`.
47
47
 
48
- 3. Use `FsmModel.fsm_graph.states` to get permit_transition you defined.
49
- 4. Use `ActiveRecord::Fsm::Graph.defined_klasses` to get all the models which really used `ActiveRecord::Fsm`.
48
+ 3. Use `FsmModel.fsm_graph.transitions` to get all permit_transition you defined.
49
+ 4. Use `FsmModel.fsm_graph.states` to get all permit_status you defined.
50
+ 5. Use `FsmModel.fsm_graph.final_states.include?(fsm_instance.status)` to judge FsmModel instance `fsm_instance` terminate?.
51
+ 6. Use `ActiveRecord::Fsm::Graph.defined_klasses` to get all the models which really used `ActiveRecord::Fsm`.
50
52
 
51
53
  e.g.
52
54
 
53
55
  ```ruby
56
+ class ApplicationRecord < ActiveRecord::Base
57
+ include ActiveRecord::Fsm
58
+
59
+ self.abstract_class = true
60
+ # blabalbla......
61
+ end
62
+
63
+ # FsmModel need call fsm_define
54
64
  class FsmModel < ApplicationRecord
55
65
  STATE_1 = 1
56
66
  STATE_2 = 2
@@ -65,12 +75,16 @@ class FsmModel < ApplicationRecord
65
75
  fsm_define(PERMIT_TRANSITIONS)
66
76
  end
67
77
 
78
+ # FsmModel can be shown having used ActiveRecord::Fsm
68
79
  ActiveRecord::Fsm::Graph.defined_klasses
69
80
  # => [FsmModel]
70
81
 
82
+ # NormalModel doesn't call fsm_define
83
+ # although inherited from ApplicationRecord
71
84
  class NormalModel < ApplicationRecord
72
85
  end
73
86
 
87
+ # NormalModel is not included
74
88
  ActiveRecord::Fsm::Graph.defined_klasses
75
89
  # => [FsmModel]
76
90
  ```
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Fsm
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-fsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ElliotCui