attribute_boolean 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/attribute_boolean.rb +3 -1
- data/test/attr_boolean_test.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f92342fed6f9922129c9ee58ade914c4fa0336c
|
4
|
+
data.tar.gz: e7d5b4b25a1ee1e0b5bacaea0ac18fc7dae65f0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10a5c233c4a1241b0ccd289fa2b1b598f01322f3ea5913a41394702582378b7d9187844c28607ce2aa14a26f1a082a2a17fb162e7e258d5e5f19d951222656b0
|
7
|
+
data.tar.gz: d8bbd96c0dffaf596e41a83afd1d2afdc5c1ca18c6e6ed678b96523802958b75e727208749a4a15aae6dcdceadf221459d72337d7001b39e38f4a031bb64f00d
|
data/lib/attribute_boolean.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module AttributeBoolean
|
2
2
|
|
3
|
-
VERSION = "1.0.
|
3
|
+
VERSION = "1.0.1"
|
4
4
|
|
5
5
|
module ClassMethods
|
6
6
|
def attr_boolean(*args)
|
@@ -40,6 +40,8 @@ module AttributeBoolean
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
alias_method "#{ name }", "#{ name }?"
|
44
|
+
|
43
45
|
define_method("#{ name }=") do |value|
|
44
46
|
is_true =
|
45
47
|
if value == nil
|
data/test/attr_boolean_test.rb
CHANGED
@@ -15,14 +15,16 @@ class AttrBooleanTest < Minitest::Test
|
|
15
15
|
def test_truthiness
|
16
16
|
[ "y", "yes", true, 1, 2, :y ].each do |value|
|
17
17
|
@obj.field = value
|
18
|
-
assert_equal true, @obj.field
|
18
|
+
assert_equal true, @obj.field, "expected field #{ value.inspect } to result in true"
|
19
|
+
assert_equal true, @obj.field?, "expected field? #{ value.inspect } to result in true"
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_falsiness
|
23
24
|
[ false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF', 'n', 'N', 'no', 'NO' ].each do |value|
|
24
25
|
@obj.field = value
|
25
|
-
assert_equal false, @obj.field
|
26
|
+
assert_equal false, @obj.field, "expected field #{ value.inspect } to result in false"
|
27
|
+
assert_equal false, @obj.field?, "expected field? #{ value.inspect } to result in false"
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|