worker_plugins 0.0.7 → 0.0.9

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: 9169da6dfadfccf39b65f247a728885152daebeef7470ea77e1ed1bd381e091b
4
- data.tar.gz: c8e77a446274d1fe6a37c1ad5ffae3450bb7819eafad511d658b7eb609dd103a
3
+ metadata.gz: af3f79b1953081fc07f554cd79338d55ffd761b4ec27783f5129089caca039f3
4
+ data.tar.gz: 6f5db87522e726efd317b146b1c2ea106335a0528a3d3466280dc98fae05f7fb
5
5
  SHA512:
6
- metadata.gz: 0244c00a1c87707a1553815f9f871f8a5309c53123dc67788a8e5ccfde9ee7a5f72d88c075c7290d40ec10533accd129c354afee1bd8e3e13ac12c61fd22b659
7
- data.tar.gz: a5d95d70f694b93c123ae85ec8b42a71e751394011c16bb1a3a577c163e796bd4a91ffc453ae201db9fa4ecd4cf2f00c785f58af8e731116a1ac56591a4efae1
6
+ metadata.gz: b4921cc75b9cf8c012257840ce1dcca05b8abb9e20c34054b367021c15783bc5b6bf9f49535ae829e3b27c37853f61c90bd6921736f333cec1c91ea05a82c4ad
7
+ data.tar.gz: 949a960c7499c29b97a8cf8c42172510c3813f5020e457e0dcf11247e7fae836880e9226744ac226a9e02f164c24517f53941cafb817205674feb2f8c9302e72
@@ -3,9 +3,10 @@ class WorkerPlugins::Workplace < WorkerPlugins::ApplicationRecord
3
3
 
4
4
  has_many :workplace_links, dependent: :destroy
5
5
 
6
- belongs_to :user, polymorphic: WorkerPlugins::UserRelationshipPolymorphic.execute!
6
+ belongs_to :user, polymorphic: WorkerPlugins::UserRelationshipPolymorphic.execute!, optional: true
7
7
 
8
8
  validates :name, presence: true
9
+ validate :validate_owner
9
10
 
10
11
  def each_resource(limit: nil, types: nil)
11
12
  count = 0
@@ -16,7 +17,7 @@ class WorkerPlugins::Workplace < WorkerPlugins::ApplicationRecord
16
17
  workplace_links.each do |workplace_link|
17
18
  yield workplace_link.resource
18
19
  count += 1
19
- return if limit && count >= limit # rubocop:disable Lint/NonLocalExitFromIterator:
20
+ return if limit && count >= limit # rubocop:disable Lint/NonLocalExitFromIterator
20
21
  end
21
22
  end
22
23
  end
@@ -59,4 +60,12 @@ private
59
60
 
60
61
  inserted_ids
61
62
  end
63
+
64
+ def validate_owner
65
+ if user.present? && session_id.present?
66
+ errors.add(:base, "Workplace can't belong to both a user and a session")
67
+ elsif user.blank? && session_id.blank?
68
+ errors.add(:base, "Workplace must belong to a user or a session")
69
+ end
70
+ end
62
71
  end
@@ -2,7 +2,7 @@ class WorkerPlugins::SwitchQuery < WorkerPlugins::ApplicationService
2
2
  arguments :query, :workplace
3
3
 
4
4
  def perform
5
- if resources_to_add.count.zero?
5
+ if resources_to_add.none?
6
6
  result = WorkerPlugins::RemoveQuery.execute!(query:, workplace:)
7
7
  succeed!(
8
8
  destroyed: result.fetch(:destroyed),
@@ -0,0 +1,9 @@
1
+ class AddSessionIdToWorkerPluginsWorkplaces < ActiveRecord::Migration[5.2]
2
+ def change
3
+ change_table :worker_plugins_workplaces, bulk: true do |t|
4
+ t.string :session_id
5
+ end
6
+
7
+ add_index :worker_plugins_workplaces, :session_id, unique: true
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module WorkerPlugins
2
- VERSION = "0.0.7".freeze
2
+ VERSION = "0.0.9".freeze
3
3
  end
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worker_plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Stöckel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-02 00:00:00.000000000 Z
11
+ date: 2026-03-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails framework for easily choosing and creating lists of objects and
14
14
  execute plugins against them.
15
15
  email:
16
- - k@spernj.org
16
+ - kasper@diestoeckels.de
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
@@ -40,6 +40,7 @@ files:
40
40
  - db/migrate/20150521114659_create_worker_plugins_workplace_links.rb
41
41
  - db/migrate/20200702072306_change_workplace_links_resource_id_to_string_to_support_uuids.rb
42
42
  - db/migrate/20210106190349_change_resource_id_to_string_to_support_uuid.rb
43
+ - db/migrate/20260322194625_add_session_id_to_worker_plugins_workplaces.rb
43
44
  - lib/tasks/worker_plugins_tasks.rake
44
45
  - lib/worker_plugins.rb
45
46
  - lib/worker_plugins/engine.rb
@@ -48,7 +49,7 @@ homepage: https://www.github.com/kaspernj/worker_plugins
48
49
  licenses: []
49
50
  metadata:
50
51
  rubygems_mfa_required: 'true'
51
- post_install_message:
52
+ post_install_message:
52
53
  rdoc_options: []
53
54
  require_paths:
54
55
  - lib
@@ -64,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
65
  version: '0'
65
66
  requirements: []
66
67
  rubygems_version: 3.4.10
67
- signing_key:
68
+ signing_key:
68
69
  specification_version: 4
69
70
  summary: Rails framework for easily choosing and creating lists of objects and execute
70
71
  plugins against them.