worker_plugins 0.0.8 → 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: e84dd175df29b54e897c3419a3651eaad8720a7448d6b6ae1213e04512257814
4
- data.tar.gz: ab7a00dbe5b64bad121b082dab5e21f577070ef64c65cf8e5bc612d348b98f64
3
+ metadata.gz: af3f79b1953081fc07f554cd79338d55ffd761b4ec27783f5129089caca039f3
4
+ data.tar.gz: 6f5db87522e726efd317b146b1c2ea106335a0528a3d3466280dc98fae05f7fb
5
5
  SHA512:
6
- metadata.gz: 34f102da30a84f0372d49a97f523587674e1aac79cc7f439e0c9214edcdc52751613d9844efa75baa60e3c2b4c4cc252e219a9a61ad8da56d1204744a2d96e55
7
- data.tar.gz: a3f2d50025aa0ea2b4672d222a11c6068f960fe3481c5a3ce5cdbe012817ea34071f67f6626134a6ff1a17f16c228d55bc2d15a0051f968d6ab61006ea9c4388
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
@@ -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.8".freeze
2
+ VERSION = "0.0.9".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worker_plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Stöckel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-10 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.
@@ -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