bitfields 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +8 -1
- data/lib/bitfields.rb +4 -0
- data/lib/bitfields/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d97ce2d0cab3c7fd6b3d21d91b95961ec0f01b2d
|
4
|
+
data.tar.gz: cd53f0020540f8d34514c6f99aca1fc1bcdcb285
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 938985833d6fac258ea5ecd54b11880781fc3b1047deec846414d9d7e7890bacefb56c227bf1c5b62088d8501282318c1d3ce8f98c3915982754e49599f11999
|
7
|
+
data.tar.gz: 946f21fa6884985c602c60ee8f535a97b53ca8effe044e812f5bdd02d1eaaf872afb779d68b667d7f82867db76521026eda4fa7b74d687d9ac27ce9d4f9f5876
|
data/Readme.md
CHANGED
@@ -13,7 +13,7 @@ user.stupid? == false
|
|
13
13
|
user.my_bits == 3
|
14
14
|
```
|
15
15
|
|
16
|
-
- records bitfield_changes `user.bitfield_changes == {foo: [false, true]}` (also `foo_was` / `foo_change` / `foo_changed?`)
|
16
|
+
- records bitfield_changes `user.bitfield_changes == {foo: [false, true]}` (also `foo_was` / `foo_change` / `foo_changed?` / `foo_became_true?`)
|
17
17
|
- adds scopes `User.foo.stupid.first` (deactivate with `bitfield ..., scopes: false`)
|
18
18
|
- builds sql `User.bitfield_sql(insane: true, stupid: false) == '(users.my_bits & 3) = 1'`
|
19
19
|
- builds index-using sql with `bitfield ... , query_mode: :in_list` and `User.bitfield_sql(insane: true, stupid: false) == 'users.my_bits IN (2, 3)'` (2 and 1+2), often slower than :bit_operator sql especially for high number of bits
|
@@ -51,6 +51,13 @@ Delete the shop when a user is no longer a seller
|
|
51
51
|
before_save :delete_shop, if: -> { |u| u.seller_change == [true, false]}
|
52
52
|
```
|
53
53
|
|
54
|
+
List fields and their respective values
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
user = User.new(insane: true)
|
58
|
+
user.bitfield_values(:my_bits) == { seller: false, insane: true, stupid: false }
|
59
|
+
```
|
60
|
+
|
54
61
|
TIPS
|
55
62
|
====
|
56
63
|
- [Upgrading] in version 0.2.2 the first field(when not given as hash) used bit 2 -> add a bogus field in first position
|
data/lib/bitfields.rb
CHANGED
@@ -90,6 +90,10 @@ module Bitfields
|
|
90
90
|
values = [bitfield_value_was(bit_name), bitfield_value(bit_name)]
|
91
91
|
values unless values[0] == values[1]
|
92
92
|
end
|
93
|
+
define_method("#{bit_name}_became_true?") do
|
94
|
+
value = bitfield_value(bit_name)
|
95
|
+
value && bitfield_value_was(bit_name) != value
|
96
|
+
end
|
93
97
|
|
94
98
|
if options[:scopes] != false
|
95
99
|
scope bit_name, bitfield_scope_options(bit_name => true)
|
data/lib/bitfields/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitfields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wwtd
|