petri_flow 0.2.2 → 0.2.3

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
  SHA256:
3
- metadata.gz: 4f413b92f6d4f452aa139f22ca407fce87cb4b8ca39b8afc3c2b09df509c8def
4
- data.tar.gz: 14a8a81e41d3581a5225c7a21d8ec0a56146886b986ada2d902521256c1da6ad
3
+ metadata.gz: 2d03bca56fe4145b890fd88b727e78ee433f8876fdcd2d08e3f8e2d20b053329
4
+ data.tar.gz: 47482a3b0c6f1f9220761487be443a99604ecf159de349ec0f131d65a8e05c4f
5
5
  SHA512:
6
- metadata.gz: 360f40f0da4d06be85a0a2f463c89ed0759e0137d356609fc28f80ae674118d11882d64f063755c33dd903a32868b7343c300ec941ca6eb86cb1aa3bda53375a
7
- data.tar.gz: 10ed23928c6cec4cf125bc02b39aef86efa6c9131632148cc2be7f366e05a66a1974825b77c9a8939fd995e30a609b51ce66f4f5a4212c7b77409aad550f85ae
6
+ metadata.gz: 3a97e0072c3ebf3aabcb165dc5fd176240ea76eaf393fca8489e7ff7497b0bfed442eb59aa161e56e7f82f73eecfaed397582acea55892abc73671be20eb4790
7
+ data.tar.gz: 6b24bda1541f835f9b89e6fa72fac5c52a03238bdee7ac67f4816128aa670712533a05d83f99d2f7c06616b5dc0919b6d6b59fa396d16b0600c471295aec7824
@@ -0,0 +1,21 @@
1
+ require 'active_support/concern'
2
+
3
+ module Wf
4
+ module ActsAsParty
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ has_one :party, as: :partable
9
+ end
10
+
11
+ module ClassMethods
12
+ def acts_as_party(options = {user: false, party_name: :name})
13
+ cattr_accessor :yaffle_text_field
14
+ self.has_many :users, foreign_key: :id if options[:user]
15
+ self.after_create do
16
+ create_party(party_name: options[:party_name])
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -13,9 +13,7 @@
13
13
  module Wf
14
14
  class Group < ApplicationRecord
15
15
  has_many :users
16
- has_one :party, as: :partable
17
- after_create do
18
- create_party(party_name: name)
19
- end
16
+ include Wf::ActsAsParty
17
+ acts_as_party(user: false, party_name: :name)
20
18
  end
21
19
  end
@@ -14,13 +14,7 @@
14
14
  module Wf
15
15
  class User < ApplicationRecord
16
16
  belongs_to :group, optional: true
17
- has_one :party, as: :partable
18
-
19
- # NOTICE: group or user or role all has_many users
20
- has_many :users, foreign_key: :id
21
-
22
- after_create do
23
- create_party(party_name: name)
24
- end
17
+ include Wf::ActsAsParty
18
+ acts_as_party(user: true, party_name: :name)
25
19
  end
26
20
  end
data/lib/wf/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wf
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petri_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hooopo Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-26 00:00:00.000000000 Z
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap
@@ -246,6 +246,7 @@ files:
246
246
  - app/jobs/wf/application_job.rb
247
247
  - app/jobs/wf/fire_timed_workitem_job.rb
248
248
  - app/mailers/wf/application_mailer.rb
249
+ - app/models/wf/acts_as_party.rb
249
250
  - app/models/wf/application_record.rb
250
251
  - app/models/wf/arc.rb
251
252
  - app/models/wf/callbacks/assignment_default.rb