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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d3c3c80e7c7bc57c3bf5b5d823ed303f2eb9334
4
- data.tar.gz: 9d6b4bba6c3d6d32da0c4d973ad73e46895628ba
3
+ metadata.gz: d97ce2d0cab3c7fd6b3d21d91b95961ec0f01b2d
4
+ data.tar.gz: cd53f0020540f8d34514c6f99aca1fc1bcdcb285
5
5
  SHA512:
6
- metadata.gz: 08c481512fb7e297ccf9d9847fa9e2973af42ec178d0209d50a4d826a28921d56b85cd8ea761b3d75726c759057c17c960be852d129cae05c8c7e7f375735c28
7
- data.tar.gz: 200eae5fcfb735aa8bc99e45310a0a565a4ed89f35b0de03b78e4eed62f841c571a37fc918c950279bf08ebe1ec2c878264638ab481de8b20b80fc216ec0f0fc
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
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Bitfields
2
- Version = VERSION = "0.6.0"
2
+ Version = VERSION = "0.7.0"
3
3
  end
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.6.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: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2016-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wwtd