forest_liana 9.5.5 → 9.5.7

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: 3d1c39075bf7b59d268ffd575ef52feb25eb8a67a370f08b4f94a1bca39288ac
4
- data.tar.gz: 3c7e36125001dd9ed399239848260652ea6736b18cf9c93a3bf7a4eba7b2497c
3
+ metadata.gz: ef02f4f1dde4cd777a5716344e1ffe08328870746e34cd4b61fe0494462765f8
4
+ data.tar.gz: f00356a4fd733f3d08cd317e0f1a74e81ff936c71b6263da013f2f9528e3a5e4
5
5
  SHA512:
6
- metadata.gz: f30ea56ebf1e756c17df2398c6746b89165fadda18427b48b3685e5f78276c5994c586f33067c366ddb132245d4a0b0c40e3a562c39a01379319ef8cd7ce84ac
7
- data.tar.gz: 57b9e0b67ca52e8f5703cd989a627f53e2eea910ba923a62f14b22482cee38ee9d0b22ac91aa38fe2f5b29a1a0244ac50cdad93f50cbfe113c73515c5c4d0cc8
6
+ metadata.gz: c7b5c5c600644678f25cac77cbef4ec5e410a1d324638abf00f897f9c9b1f4683ae1f94f9b11a9a643a803881f9160ebc2b6fdad72cab124a3a09a4e38d06475
7
+ data.tar.gz: 1c20cb1fb9457418ef6aa7d91bb68d842a9d311b484c95be108b6a1b848b74a022e8370cfa3c56685cdae91c550c6ebbbb5031b2a11e357461addd34d66e705c
@@ -446,7 +446,11 @@ module ForestLiana
446
446
  def add_validations(column_schema, column)
447
447
  # NOTICE: Do not consider validations if a before_validation Active Records
448
448
  # Callback is detected.
449
- if @model._validation_callbacks.map(&:kind).include? :before
449
+ default_callback_excluded = [:normalize_changed_in_place_attributes]
450
+ if @model._validation_callbacks
451
+ .reject { |callback| default_callback_excluded.include?(callback.filter) }
452
+ .map(&:kind).include?(:before)
453
+
450
454
  return column_schema
451
455
  end
452
456
 
@@ -24,11 +24,15 @@ module ForestLiana::Collection
24
24
  end
25
25
 
26
26
  def action(name, opts = {})
27
+ return if model.actions.find { |action| action.name == name }
28
+
27
29
  opts[:name] = name
28
30
  model.actions << ForestLiana::Model::Action.new(opts)
29
31
  end
30
32
 
31
33
  def segment(name, opts = {}, &block)
34
+ return if model.segments.find { |segment| segment.name == name }
35
+
32
36
  opts[:name] = name
33
37
  model.segments << ForestLiana::Model::Segment.new(opts, &block)
34
38
  end
@@ -74,12 +78,14 @@ module ForestLiana::Collection
74
78
  opts[:validations] = [] unless opts.has_key?(:validations)
75
79
  opts[:is_virtual] = true unless opts.has_key?(:polymorphic_key) && opts[:polymorphic_key]
76
80
 
77
- model.fields << opts.merge({
81
+ field = opts.merge({
78
82
  field: name,
79
83
  is_filterable: !!opts[:is_filterable],
80
84
  is_sortable: !!opts[:is_sortable],
81
85
  })
82
86
 
87
+ add_field(field)
88
+
83
89
  define_method(name) { self.data[name] } if smart_collection?
84
90
 
85
91
  if serializer_name && ForestLiana::UserSpace.const_defined?(
@@ -108,13 +114,15 @@ module ForestLiana::Collection
108
114
  end
109
115
 
110
116
  def has_many(name, opts, &block)
111
- model.fields << opts.merge({
117
+ field = opts.merge({
112
118
  field: name,
113
119
  is_virtual: true,
114
120
  is_searchable: false,
115
121
  type: ['String']
116
122
  })
117
123
 
124
+ add_field(field)
125
+
118
126
  define_method(name) { self.data[name] } if smart_collection?
119
127
 
120
128
  if serializer_name && ForestLiana::UserSpace.const_defined?(
@@ -126,13 +134,15 @@ module ForestLiana::Collection
126
134
  end
127
135
 
128
136
  def belongs_to(name, opts, &block)
129
- model.fields << opts.merge({
137
+ field = opts.merge({
130
138
  field: name,
131
139
  is_virtual: true,
132
140
  is_searchable: false,
133
141
  type: 'String'
134
142
  })
135
143
 
144
+ add_field(field)
145
+
136
146
  define_method(name) { self.data[name] } if smart_collection?
137
147
 
138
148
  if serializer_name && ForestLiana::UserSpace.const_defined?(
@@ -145,6 +155,12 @@ module ForestLiana::Collection
145
155
 
146
156
  private
147
157
 
158
+ def add_field(field)
159
+ return if model.fields.find { |field| field[:field] == name }
160
+
161
+ model.fields << field
162
+ end
163
+
148
164
  def find_name(collection_name)
149
165
  # TODO: Remove once lianas prior to 2.0.0 are not supported anymore.
150
166
  model = ForestLiana.models.find { |collection| collection.try(:table_name) == collection_name.to_s }
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "9.5.5"
2
+ VERSION = "9.5.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.5.5
4
+ version: 9.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-09 00:00:00.000000000 Z
11
+ date: 2024-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails