easy_flow 0.7.0 → 0.8.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
  SHA256:
3
- metadata.gz: d808d59c87ec6f8b6eee1e9032bdab397bf4df8035e6248f24f1d404db59b8bb
4
- data.tar.gz: ad2551396fcf8348fb87270287e31d29780514374877735e31fc50ffe8c63d77
3
+ metadata.gz: c42186355c5aff4867710d2b43d50543a34be2ce290c9748bea1ab11b540e21c
4
+ data.tar.gz: e0a902db995da05a8fed9e1c8f841b90f252277f31e2867d59a43a7855bcfa03
5
5
  SHA512:
6
- metadata.gz: 7d0a900d84901dab3444fc04eb9bd84cf12cad6d4eaa463d11c3ecb72e904f02ad48be7882e50965b275c920e7134023f298224c56f679b0f903fa74b8189271
7
- data.tar.gz: 6c8b9bf2f4c7aa3581d9b445ce01ba203646e8023a7107266d6d6ab8e94e536b29c2af38ff0b4dd415745d80160da5a9c2906680f227f9674a21665edece86aa
6
+ metadata.gz: 907fdb2b8760253cf3eea079d3dbbd92d23050d296b9c1166b8150dd5d6cff1e52b1b5f069a65b2111786808bfbcf9e097125f92b60a7e725dc958cde58b73df
7
+ data.tar.gz: 7db26de4465197e8983fd84c44f2bb2cc78cd79d4a999606adf11b8fa49a3af68699d19b96fa0686355bd53f5b0eaac93126627d7c37eb9b6aa2cb7c3dacc880
@@ -17,5 +17,11 @@ module EasyFlow
17
17
  def flow_host
18
18
  @flow_host ||= EasyFlow.host_named(self.class.named_flow_host || request.path_parameters[:easy_flow_host])
19
19
  end
20
+
21
+ def hosted_flows
22
+ return flow_host.flows unless flow_host.owner_method
23
+
24
+ flow_host.flows.where(owner: send(flow_host.owner_method))
25
+ end
20
26
  end
21
27
  end
@@ -91,13 +91,13 @@ module EasyFlow
91
91
  end
92
92
 
93
93
  def admitted_run
94
- found = Run.where(flow: flow_host.flows).find(params[:id])
94
+ found = Run.where(flow: hosted_flows).find(params[:id])
95
95
 
96
96
  Admission.of_run(found, permitted: permitted?(found.flow))
97
97
  end
98
98
 
99
99
  def flow
100
- @stored_flow ||= admit(flow_host.flows.find_by(slug: params[:slug]))
100
+ @stored_flow ||= admit(hosted_flows.find_by(slug: params[:slug]))
101
101
  end
102
102
 
103
103
  def flowing_definition(flow)
@@ -83,7 +83,7 @@ module EasyFlow
83
83
  end
84
84
 
85
85
  def flow
86
- @flow ||= flow_host.flows.find(params[:flow_id])
86
+ @flow ||= hosted_flows.find(params[:flow_id])
87
87
  end
88
88
 
89
89
  def document
@@ -2,11 +2,11 @@ module EasyFlow
2
2
  module Manage
3
3
  class DefinitionsController < BaseController
4
4
  def edit
5
- @flow = flow_host.flows.find(params[:flow_id])
5
+ @flow = hosted_flows.find(params[:flow_id])
6
6
  end
7
7
 
8
8
  def update
9
- @flow = flow_host.flows.find(params[:flow_id])
9
+ @flow = hosted_flows.find(params[:flow_id])
10
10
  @flow.edit_history.edit_document(JSON.parse(params.require(:definition)))
11
11
  redirect_to manage_flow_path(@flow), notice: "Definition saved."
12
12
  end
@@ -7,7 +7,7 @@ module EasyFlow
7
7
  end
8
8
 
9
9
  def create
10
- @flow = flow_host.flows.new(create_params)
10
+ @flow = hosted_flows.new(create_params)
11
11
 
12
12
  if @flow.save
13
13
  redirect_to manage_flow_path(@flow), notice: "Flow created."
@@ -18,29 +18,29 @@ module EasyFlow
18
18
  end
19
19
 
20
20
  def show
21
- @flow = flow_host.flows.find(params[:id])
21
+ @flow = hosted_flows.find(params[:id])
22
22
  @canvas = canvas_payload(@flow)
23
23
  end
24
24
 
25
25
  def edit
26
- @flow = flow_host.flows.find(params[:id])
26
+ @flow = hosted_flows.find(params[:id])
27
27
  end
28
28
 
29
29
  def update
30
- @flow = flow_host.flows.find(params[:id])
30
+ @flow = hosted_flows.find(params[:id])
31
31
  @flow.update!(flow_params)
32
32
  redirect_to manage_flow_path(@flow), notice: "Saved."
33
33
  end
34
34
 
35
35
  def destroy
36
- flow_host.flows.find(params[:id]).destroy!
36
+ hosted_flows.find(params[:id]).destroy!
37
37
  redirect_to manage_flows_path, notice: "Flow removed."
38
38
  end
39
39
 
40
40
  private
41
41
 
42
42
  def ordered_flows
43
- flow_host.flows.order(:slug)
43
+ hosted_flows.order(:slug)
44
44
  end
45
45
 
46
46
  def create_params
@@ -27,7 +27,7 @@ module EasyFlow
27
27
  end
28
28
 
29
29
  def previewed
30
- @previewed ||= flow_host.flows.find(params[:flow_id])
30
+ @previewed ||= hosted_flows.find(params[:flow_id])
31
31
  end
32
32
 
33
33
  def admit(_flow)
@@ -15,7 +15,7 @@ module EasyFlow
15
15
  private
16
16
 
17
17
  def flow
18
- @flow ||= flow_host.flows.find(params[:flow_id])
18
+ @flow ||= hosted_flows.find(params[:flow_id])
19
19
  end
20
20
  end
21
21
  end
@@ -6,6 +6,8 @@ module EasyFlow
6
6
  enum :kind, { scored: "scored", guide: "guide" }
7
7
  enum :persists, { unsaved: "unsaved", each_step: "each_step", on_finish: "on_finish" }
8
8
 
9
+ belongs_to :owner, polymorphic: true, optional: true
10
+
9
11
  validates :host, :slug, presence: true
10
12
 
11
13
  after_initialize :begin_the_flow, if: :new_record?
@@ -18,7 +20,7 @@ module EasyFlow
18
20
  has_many :definition_versions, class_name: "EasyFlow::Version", foreign_key: :flow_id, dependent: :destroy
19
21
 
20
22
  def self.upsert_definition(definition, host:)
21
- find_or_initialize_by(host: host, slug: definition["slug"]).tap do |flow|
23
+ find_or_initialize_by(host: host, owner: nil, slug: definition["slug"]).tap do |flow|
22
24
  flow.save!
23
25
  flow.record_definition(definition) unless flow.definition == definition
24
26
  end
@@ -0,0 +1,10 @@
1
+ class AddOwnerToEasyFlowDefinitions < ActiveRecord::Migration[8.1]
2
+ def change
3
+ add_reference :easy_flow_definitions, :owner, polymorphic: true, index: false
4
+ remove_index :easy_flow_definitions, [ :host, :slug ], unique: true, name: "index_easy_flow_definitions_on_host_and_slug"
5
+ add_index :easy_flow_definitions, [ :host, :slug ], unique: true, where: "owner_id IS NULL",
6
+ name: "index_easy_flow_definitions_on_host_and_slug"
7
+ add_index :easy_flow_definitions, [ :host, :owner_type, :owner_id, :slug ], unique: true, where: "owner_id IS NOT NULL",
8
+ name: "index_easy_flow_definitions_on_host_owner_and_slug"
9
+ end
10
+ end
@@ -2,7 +2,7 @@ module EasyFlow
2
2
  class Host
3
3
  attr_reader :name
4
4
  attr_writer :layout, :admin_layout, :offers
5
- attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method
5
+ attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method
6
6
 
7
7
  def initialize(name)
8
8
  @name = name.to_s
@@ -1,3 +1,3 @@
1
1
  module EasyFlow
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -137,6 +137,7 @@ files:
137
137
  - db/migrate/20260924120100_create_easy_flow_versions.rb
138
138
  - db/migrate/20260924120200_create_easy_flow_runs.rb
139
139
  - db/migrate/20260924130000_add_host_to_easy_flow_definitions.rb
140
+ - db/migrate/20261001120000_add_owner_to_easy_flow_definitions.rb
140
141
  - lib/easy_flow.rb
141
142
  - lib/easy_flow/engine.rb
142
143
  - lib/easy_flow/host.rb