petri_flow 0.2.3 → 0.2.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
  SHA256:
3
- metadata.gz: 2d03bca56fe4145b890fd88b727e78ee433f8876fdcd2d08e3f8e2d20b053329
4
- data.tar.gz: 47482a3b0c6f1f9220761487be443a99604ecf159de349ec0f131d65a8e05c4f
3
+ metadata.gz: '08a1f7f65f84fd9f8ffbdec71efa97d6c5d9fba3446857a5f08b69930fe734a9'
4
+ data.tar.gz: f64502b080933aae92cd9b61b027f3451e4f4e7ec90fd45bcf67857c23ce7ddc
5
5
  SHA512:
6
- metadata.gz: 3a97e0072c3ebf3aabcb165dc5fd176240ea76eaf393fca8489e7ff7497b0bfed442eb59aa161e56e7f82f73eecfaed397582acea55892abc73671be20eb4790
7
- data.tar.gz: 6b24bda1541f835f9b89e6fa72fac5c52a03238bdee7ac67f4816128aa670712533a05d83f99d2f7c06616b5dc0919b6d6b59fa396d16b0600c471295aec7824
6
+ metadata.gz: 856886ed111aab29361a47b1e24ef17d1a5340d0d3d4838581ccfb852a24f8cfabca81fcb6548396a574e471b7086b1e87e73be907cbc8231bf8fe6546c284ac
7
+ data.tar.gz: ff320c2ed77ec2021f78054a8cd23cdeae188e78494deda3bbd534a94399c7e36ef16fae550414f26d5c54ed95d78a3473e2a5c5b49023735c38ffb1c264737a
data/README.md CHANGED
@@ -82,26 +82,26 @@ Wf.org_classes = { group: "::Group" }
82
82
 
83
83
  Set parties:
84
84
 
85
- ```ruby
86
- class User < ApplicationRecord
87
- belongs_to :group, optional: true
88
- has_one :party, as: :partable, class_name: 'Wf::Party'
89
-
90
- # NOTICE: group or user or role all has_many users
91
- has_many :users, foreign_key: :id
85
+ For normal org model, for example group or role etc.
92
86
 
93
- after_create do
94
- create_party(party_name: name)
87
+ ```ruby
88
+ module Wf
89
+ class Group < ApplicationRecord
90
+ has_many :users
91
+ include Wf::ActsAsParty
92
+ acts_as_party(user: false, party_name: :name)
95
93
  end
96
94
  end
97
95
  ```
98
96
 
97
+ For user model:
98
+
99
99
  ```ruby
100
- class Group < ApplicationRecord
101
- has_many :users
102
- has_one :party, as: :partable, class_name: 'Wf::Party'
103
- after_create do
104
- create_party(party_name: name)
100
+ module Wf
101
+ class User < ApplicationRecord
102
+ belongs_to :group, optional: true
103
+ include Wf::ActsAsParty
104
+ acts_as_party(user: true, party_name: :name)
105
105
  end
106
106
  end
107
107
  ```
@@ -1,21 +1,23 @@
1
- require 'active_support/concern'
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
2
4
 
3
5
  module Wf
4
6
  module ActsAsParty
5
- extend ActiveSupport::Concern
6
-
7
+ extend ActiveSupport::Concern
8
+
7
9
  included do
8
10
  has_one :party, as: :partable
9
11
  end
10
-
12
+
11
13
  module ClassMethods
12
- def acts_as_party(options = {user: false, party_name: :name})
14
+ def acts_as_party(options = { user: false, party_name: :name })
13
15
  cattr_accessor :yaffle_text_field
14
- self.has_many :users, foreign_key: :id if options[:user]
15
- self.after_create do
16
+ has_many :users, foreign_key: :id if options[:user]
17
+ after_create do
16
18
  create_party(party_name: options[:party_name])
17
19
  end
18
20
  end
19
21
  end
20
22
  end
21
- end
23
+ end
@@ -4,9 +4,9 @@ module Wf::Callbacks
4
4
  class AssignmentDefault < ApplicationJob
5
5
  queue_as :default
6
6
 
7
- def perform(*guests)
8
- $stdout.puts(guests.inspect)
9
- [] # return blank default
7
+ def perform(_workitem_id)
8
+ # return Party array.
9
+ []
10
10
  end
11
11
  end
12
12
  end
@@ -17,9 +17,11 @@ module Wf::CaseCommand
17
17
  end
18
18
 
19
19
  unless has_case_ass
20
- callback_values = workitem.transition.assignment_callback.constantize.new(workitem.id).perform
21
- if callback_values.present?
22
- # TODO: do assignment for callback.
20
+ callback_parties = workitem.transition.assignment_callback.constantize.new.perform(workitem.id)
21
+ if callback_parties.present?
22
+ callback_parties.each do |party|
23
+ AddWorkitemAssignment.call(workitem, party, false)
24
+ end
23
25
  else
24
26
  workitem.transition.transition_static_assignments.each do |static_assignment|
25
27
  AddWorkitemAssignment.call(workitem, static_assignment.party, false)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # == Schema Information
3
4
  #
4
5
  # Table name: wf_transitions
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.3"
4
+ VERSION = "0.2.4"
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.3
4
+ version: 0.2.4
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-27 00:00:00.000000000 Z
11
+ date: 2020-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap