klastera 1.4.3 → 1.4.4

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: e524bc600751df634962778af44d6b9bd782cabdf7a125a145d2a7efbfbe6950
4
- data.tar.gz: ab457168729e69d5f1ca94f40ea667b78e3610993eaa686998e8aa792f865db1
3
+ metadata.gz: c15103fa238ee96065a307c2e8e4d30e99488174d0c1f6cd47cf76752998e37c
4
+ data.tar.gz: e6d79698657b081437e62238c3925e5346a4b47b17f5e4671f11bfeb7f6806a8
5
5
  SHA512:
6
- metadata.gz: f30c250c13e081a7aebeb66fce89386638d445a92f5dd995c4855483a45efd7bf7927265980fff8ffcef7ca3e9d3f5fc53c618b05babc92464a6986a8878df84
7
- data.tar.gz: 97007ff678bbc223506ac5fc53814c9b7363c3e45ba4f39455f73d8abdd1012bab6fd7b126b3237cc42b91fbbb6a969061c72ece12549aa1d84ae0810522a43a
6
+ metadata.gz: 3e39ddb9802da7ed9f31e320e8ac36f5f26cb2fe8a4d09065c5de22fee3851e7593b08cd7223455dfdf19a718d63a98610269c2c9702e51160834938181f47d7
7
+ data.tar.gz: 2a2f371d207ce603d3887a86cedabe5451d3edc056b5549361c46dfa0ed8a0c64aa7e4897251db7683457880c5b2868f374067690a5a9c5d34c0f92f3863f32f
@@ -1,6 +1,9 @@
1
1
  module Klastera::Concerns::Clusterizable
2
2
  extend ActiveSupport::Concern
3
+
3
4
  included do
5
+ class MutipleClustersOperationError < StandardError; end
6
+
4
7
  belongs_to :cluster
5
8
 
6
9
  has_many :cluster_entities, as: :entity, class_name: Klastera::ClusterEntity
@@ -18,6 +21,10 @@ module Klastera::Concerns::Clusterizable
18
21
  end
19
22
  end
20
23
 
24
+ def allow_multiple_clusters?(default=:one)
25
+ organization.cluster_cardinality_of(self.class, default: default) == :many
26
+ end
27
+
21
28
  ##
22
29
  # This is a legacy method and we don't recommend using it.
23
30
  # Implement directly Klastera.entity_clusters_string_list instead of this method.
@@ -1,7 +1,7 @@
1
1
  module Klastera::Concerns::Organization
2
2
  extend ActiveSupport::Concern
3
3
  included do
4
-
4
+ serialize :cluster_config
5
5
  has_many :clusters
6
6
 
7
7
  validates :use_cluster_as, inclusion: { in: ::Cluster::MODES.map{|m|m.to_s}, message: I18n.t('klastera.clusters.wrong_option') }, if: proc{ use_cluster_as.present? }
@@ -11,6 +11,17 @@ module Klastera::Concerns::Organization
11
11
  self.use_cluster_as.to_s.to_sym
12
12
  end
13
13
 
14
+ def cluster_cardinality_of(entity, default: :many)
15
+ if cluster_config.is_a?(Hash)
16
+ entities_cardinality = cluster_config[:entities]&.[](:cardinality)||{}
17
+ entity = entity.to_s.to_sym
18
+ if entities_cardinality.has_key?(entity)
19
+ default = entities_cardinality[entity]
20
+ end
21
+ end
22
+ default.to_s.to_sym
23
+ end
24
+
14
25
  ##
15
26
  # Return a boolean if one of three of options was set in organization
16
27
  # As useless option you can retrieve the value passing false as argument.
@@ -0,0 +1,5 @@
1
+ class AddClusterConfigToOrganization < ActiveRecord::Migration
2
+ def change
3
+ add_column :organizations, :cluster_config, :text
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Klastera
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klastera
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gino Barahona
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-08 00:00:00.000000000 Z
11
+ date: 2020-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -93,6 +93,7 @@ files:
93
93
  - db/migrate/20200330010551_create_klastera_cluster_users.rb
94
94
  - db/migrate/20200330221601_add_order_field_to_clusters.rb
95
95
  - db/migrate/20200518142609_create_klastera_cluster_entities.rb
96
+ - db/migrate/20200908180057_add_cluster_config_to_organization.rb
96
97
  - lib/klastera.rb
97
98
  - lib/klastera/engine.rb
98
99
  - lib/klastera/version.rb
@@ -127,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
128
  - !ruby/object:Gem::Version
128
129
  version: '0'
129
130
  requirements: []
130
- rubygems_version: 3.1.2
131
+ rubygems_version: 3.0.8
131
132
  signing_key:
132
133
  specification_version: 4
133
134
  summary: Clusterization Engine