klastera 1.4.4 → 1.4.4.1

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: c15103fa238ee96065a307c2e8e4d30e99488174d0c1f6cd47cf76752998e37c
4
- data.tar.gz: e6d79698657b081437e62238c3925e5346a4b47b17f5e4671f11bfeb7f6806a8
3
+ metadata.gz: ef0519c775285f8e1684e2b7710f6a2729d89335f4742a04f4267a156870746d
4
+ data.tar.gz: 87adbf443e12d8dc8eb93a6d40dd7518d138dea65c404fc8ac19e9a69ea7a742
5
5
  SHA512:
6
- metadata.gz: 3e39ddb9802da7ed9f31e320e8ac36f5f26cb2fe8a4d09065c5de22fee3851e7593b08cd7223455dfdf19a718d63a98610269c2c9702e51160834938181f47d7
7
- data.tar.gz: 2a2f371d207ce603d3887a86cedabe5451d3edc056b5549361c46dfa0ed8a0c64aa7e4897251db7683457880c5b2868f374067690a5a9c5d34c0f92f3863f32f
6
+ metadata.gz: 252b2cc54c25a5d1338d7064610ff2806c4e246f44f1101809fe97b5d0167e9d75de71994f1820e67f0e9c26e164be36ea2fd6ee0922eea9c8152c4ebbce83bb
7
+ data.tar.gz: 573ef0536c76d2fb6b199ac188cc90ec8f04b780f4d2562a6772b3f73051e77f62d4897ecc633fd3b869ae5d4c5f97a536bb31ebcf13a1c8c58904a37d326d4c
@@ -9,8 +9,8 @@ module Klastera::Concerns::Clusterizable
9
9
  has_many :cluster_entities, as: :entity, class_name: Klastera::ClusterEntity
10
10
  accepts_nested_attributes_for :cluster_entities, reject_if: :all_blank, allow_destroy: true
11
11
 
12
- validates :cluster_id, presence: true, if: proc { self.try(:cluster_id) && self.organization.required_suborganization_mode? }
13
- validate :at_least_one_cluster_entity, if: proc { self.organization.required_suborganization_mode? }
12
+ validates :cluster_id, presence: true, if: -> { cluster_id.present? && organization.present? && organization.required_suborganization_mode? }
13
+ validate :at_least_one_cluster_entity, if: -> { organization.present? && organization.required_suborganization_mode? }
14
14
  validate :uniqueness_of_cluster_entity_record
15
15
 
16
16
  scope :includes_cluster, -> { includes(cluster_entities: :cluster) }
@@ -22,7 +22,7 @@ module Klastera::Concerns::Clusterizable
22
22
  end
23
23
 
24
24
  def allow_multiple_clusters?(default=:one)
25
- organization.cluster_cardinality_of(self.class, default: default) == :many
25
+ organization.present? && organization.cluster_cardinality_of(self.class, default: default) == :many
26
26
  end
27
27
 
28
28
  ##
@@ -32,7 +32,7 @@ module Klastera::Concerns::Clusterizable
32
32
  ##
33
33
  def clusters_string_separated_by(separator,attribute=:name)
34
34
  Klastera.entity_clusters_string_list!(
35
- self.cluster_entities, separator, attribute
35
+ cluster_entities, separator, attribute
36
36
  )
37
37
  end
38
38
 
@@ -11,29 +11,29 @@ module Klastera::Concerns::User
11
11
 
12
12
  has_many :cluster_users, inverse_of: :user, class_name: ::ClusterUser.to_s
13
13
  accepts_nested_attributes_for :cluster_users, reject_if: :all_blank, allow_destroy: true
14
- validates :cluster_role, presence: true, if: proc{ self.organization.is_in_cluster_mode? }
15
- validates :cluster_role, inclusion: { in: CLUSTER_ROLES , message: I18n.t('klastera.clusters.wrong_option') }, if: proc{ cluster_role.present? }
16
- validate :at_least_one_role, if: proc{ self.use_cluster? && self.try(:need_cluster_assignation?) }
14
+ validates :cluster_role, presence: true, if: -> { organization.present? && organization.is_in_cluster_mode? }
15
+ validates :cluster_role, inclusion: { in: CLUSTER_ROLES , message: I18n.t('klastera.clusters.wrong_option') }, if: -> { cluster_role.present? }
16
+ validate :at_least_one_role, if: -> { use_cluster? && try(:need_cluster_assignation?) }
17
17
 
18
- def use_cluster?; self.cluster_role.present?; end
18
+ def use_cluster?; cluster_role.present?; end
19
19
 
20
- def is_a_cluster_root?; self.cluster_role == CLUSTER_ROOT; end
21
- def is_a_cluster_admin?; self.cluster_role == CLUSTER_ADMIN; end
22
- def is_a_cluster_user?; self.cluster_role == CLUSTER_USER; end
20
+ def is_a_cluster_root?; cluster_role == CLUSTER_ROOT; end
21
+ def is_a_cluster_admin?; cluster_role == CLUSTER_ADMIN; end
22
+ def is_a_cluster_user?; cluster_role == CLUSTER_USER; end
23
23
 
24
24
  def need_cluster_assignation?
25
- self.try(:organization).try(:required_suborganization_mode?) && self.is_a_cluster_user?
25
+ organization.present? && organization.required_suborganization_mode? && is_a_cluster_user?
26
26
  end
27
27
 
28
28
  def can_admin_clusters?
29
- self.organization.is_in_cluster_mode? && ( self.is_a_cluster_admin? || self.is_a_cluster_root? )
29
+ organization.present? && organization.is_in_cluster_mode? && ( is_a_cluster_admin? || is_a_cluster_root? )
30
30
  end
31
31
 
32
32
  #
33
33
  # It tells if this user should see what they cluster role or organization dictates
34
34
  # Adminers and users from show cluster modes skip cluster clause
35
35
  def cannot_skip_cluster_clause?
36
- ! ( self.is_a_cluster_admin? || self.is_a_cluster_root? || ( self.organization.optional_suborganization_mode? && self.cluster_users.blank? ) )
36
+ ! ( is_a_cluster_admin? || is_a_cluster_root? || ( organization.present? && organization.optional_suborganization_mode? && cluster_users.blank? ) )
37
37
  end
38
38
 
39
39
  #
@@ -43,9 +43,9 @@ module Klastera::Concerns::User
43
43
  # cluster_id is present (on show/use mode organizations).
44
44
  #
45
45
  def try_to_clusterify!(role,cluster_ids)
46
- if self.try(:organization).try(:is_in_cluster_mode?)
46
+ if organization.present? && organization.is_in_cluster_mode?
47
47
  self.cluster_role = role
48
- if self.try(:organization).try(:required_suborganization_mode?) || cluster_ids.present?
48
+ if ( organization.present? && organization.required_suborganization_mode? ) || cluster_ids.present?
49
49
  timestamp = DateTime.now.to_i
50
50
  nested_attributes = {}
51
51
  cluster_ids.each do |cluster_id|
@@ -1,3 +1,3 @@
1
1
  module Klastera
2
- VERSION = "1.4.4"
2
+ VERSION = "1.4.4.1"
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.4
4
+ version: 1.4.4.1
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-09-11 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubygems_version: 3.0.8
131
+ rubygems_version: 3.1.2
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Clusterization Engine