flag_shih_tzu 0.3.6 → 0.3.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
  SHA1:
3
- metadata.gz: 3f3864c6fe734d0dc27d87b88a46085d57beed02
4
- data.tar.gz: ea62d27e9fdf6749183a2720345b02efe34048a5
3
+ metadata.gz: 3c9ecb9654411ac0213bcc2e6c0942dcc12142c1
4
+ data.tar.gz: 29cb7d8958165e9fb98929e71a658ed8fdbf338b
5
5
  SHA512:
6
- metadata.gz: 0334d4da71237808fe90c033212b9c6dbc107b0a8ea6f63f79e02607ab8bdf76c667d11f0ff015c68007eefabf508d50e568143defb0e50e794f899f3c65b14e
7
- data.tar.gz: 0145457f64fea344bbb589df30c537e178f5f4fc59e993522d3d2d8289ad677b4fb11f74bcea80a61a59ffe4261c9c5b74027392cbddbc852c79ed6357060b2e
6
+ metadata.gz: 28d35a352d8668e8bdcf8c0d1397b1c5052ae3262aaddc01d85f8f51e650fdee25c4d5928411d85bac44be4267e9619f36fa3369a309ce230641049681527657
7
+ data.tar.gz: ee18826fd3dabd765164a8dbfeeb36bab661d62bcbecc6615a297f5b5dd7cb751bca7c9744276105c344ac8cd1d4ab8dbb43b00fc00d3fba5d46ca6e784ad7fa
data/lib/flag_shih_tzu.rb CHANGED
@@ -208,12 +208,13 @@ module FlagShihTzu
208
208
 
209
209
  private
210
210
 
211
- def max_flag_value_for_column(colmn)
212
- flag_mapping[colmn].values.max
211
+ def flag_value_range_for_column(colmn)
212
+ max = flag_mapping[colmn].values.max
213
+ Range.new(0, (2 * max) - 1)
213
214
  end
214
215
 
215
216
  def chained_flags_values(colmn, *args)
216
- val = (1..(2 * max_flag_value_for_column(colmn))).to_a
217
+ val = flag_value_range_for_column(colmn).to_a
217
218
  args.each do |flag|
218
219
  neg = false
219
220
  if flag.to_s.match /^not_/
@@ -296,8 +297,7 @@ module FlagShihTzu
296
297
  # returns an array of integers suitable for a SQL IN statement.
297
298
  def sql_in_for_flag(flag, colmn)
298
299
  val = flag_mapping[colmn][flag]
299
- num = 2 * max_flag_value_for_column(colmn)
300
- (1..num).select {|i| i & val == val}
300
+ flag_value_range_for_column(colmn).select {|i| i & val == val}
301
301
  end
302
302
 
303
303
  def sql_set_for_flag(flag, colmn, enabled = true, custom_table_name = self.table_name)
@@ -1,3 +1,3 @@
1
1
  module FlagShihTzu
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
@@ -396,11 +396,15 @@ class FlagShihTzuClassMethodsTest < Test::Unit::TestCase
396
396
  spaceship_3.enable_flag(:shields)
397
397
  spaceship_3.save!
398
398
  spaceship_3.reload
399
+ spaceship_4 = Spaceship.new
400
+ spaceship_4.save!
401
+ spaceship_4.reload
399
402
  assert_equal 2, Spaceship.chained_flags_with("flags", :warpdrive).count
400
403
  assert_equal 1, Spaceship.chained_flags_with("flags", :warpdrive, :shields).count
401
404
  assert_equal 1, Spaceship.chained_flags_with("flags", :warpdrive, :not_shields).count
402
405
  assert_equal 0, Spaceship.chained_flags_with("flags", :not_warpdrive, :shields, :electrolytes).count
403
406
  assert_equal 1, Spaceship.chained_flags_with("flags", :not_warpdrive, :shields, :not_electrolytes).count
407
+ assert_equal 1, Spaceship.chained_flags_with("flags", :not_warpdrive, :not_shields, :not_electrolytes).count
404
408
  end
405
409
 
406
410
  def test_should_not_define_named_scopes_if_not_wanted
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flag_shih_tzu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-08-29 00:00:00.000000000 Z
15
+ date: 2013-10-25 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord