create_custom_attributes 0.6.2 → 0.6.3

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: 6a025789bdf522713dc791d1a425f9846940c0d3fc2d828cd7c511890bb6d1c2
4
- data.tar.gz: 26482dac5817a7e72824897b7c2d68c6a407190069e519acc667d986e404717b
3
+ metadata.gz: cfc0f2cee77429347fd5b147254475dde430f436d0bddcd34cdf79ac57a137b8
4
+ data.tar.gz: f0d2d676dec9c047efaa99bb3ff17a31718f7c64dc41f1bef24e447c89536290
5
5
  SHA512:
6
- metadata.gz: b0c468f3313e8c073ad61fa97f414fddc0b82ade5294908dda346783b4b8a77bd2d57f271eec381be070bbe386110d1151447e32f6cdc08149f451ec569c513b
7
- data.tar.gz: 98a62c90dedbbadee34436256bad7b6bd593d999e138099735b3d5471aa337262a38cbd8ad0a7347a241c427bf94933c4eae97252f4949000a5f185f2fc735f6
6
+ metadata.gz: 44b5c345a4f4ad50784696fb892b67f62524ce97b0741ee8b0e1afdf9396172aee09769f39d3f447baafbfcbbf3f88f1b98020bdd748bcbd21a46fd54b06ab27
7
+ data.tar.gz: a3335e2608599d3e276118d873b539d6305ef5b80a514d628811219e7acb940def2a665595b09d18cd14a12cbffdf503b20bdf8679b9125562536184dc8138ec
@@ -88,7 +88,7 @@ module CustomAttributes
88
88
  end
89
89
  end
90
90
 
91
- if position.present? && self.class.where(position: position, model_type: model_type).where.not(id: id).count > 0
91
+ if position.present? && self.class.where(position: position, model_type: model_type).where.not(id: id).where(custom_scope).count > 0
92
92
  errors.add :position, ::I18n.t('activerecord.errors.messages.invalid_position')
93
93
  end
94
94
  end
@@ -180,7 +180,7 @@ module CustomAttributes
180
180
  def set_position
181
181
  return unless position.nil?
182
182
 
183
- last_position = self.class.where(model_type: model_type).order(position: :desc).first.try(:position)
183
+ last_position = self.class.where(model_type: model_type).where(custom_scope).order(position: :desc).first.try(:position)
184
184
  self.position = 1
185
185
  self.position = last_position + 1 unless last_position.nil?
186
186
  end
@@ -188,7 +188,7 @@ module CustomAttributes
188
188
  def change_position_by(diff)
189
189
  new_pos = position + diff unless position.nil?
190
190
 
191
- swap_field = self.class.find_by(model_type: model_type, position: new_pos)
191
+ swap_field = self.class.find_by(model_type: model_type, position: new_pos).where(custom_scope)
192
192
 
193
193
  if swap_field.present?
194
194
  swap_field.position = position
@@ -213,7 +213,7 @@ module CustomAttributes
213
213
 
214
214
  def ensure_position_integrity
215
215
  expected_position = 1
216
- self.class.where(model_type: model_type).order(position: :asc).each do |field|
216
+ self.class.where(model_type: model_type).order(position: :asc).where(custom_scope).each do |field|
217
217
  if expected_position != field.position
218
218
  field.position = expected_position
219
219
  field.save
@@ -1,3 +1,3 @@
1
1
  module CustomAttributes
2
- VERSION = '0.6.2'.freeze
2
+ VERSION = '0.6.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: create_custom_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Grützmacher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-07 00:00:00.000000000 Z
11
+ date: 2019-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails