maybe_so 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +1 -1
- data/README.md +33 -3
- data/lib/maybe_so/active_model.rb +2 -1
- data/lib/maybe_so/active_model/boolean_attribute.rb +0 -1
- data/lib/maybe_so/core_ext.rb +1 -1
- data/lib/maybe_so/core_ext/false_class.rb +0 -2
- data/lib/maybe_so/core_ext/{fixnum.rb → integer.rb} +1 -3
- data/lib/maybe_so/core_ext/nil_class.rb +0 -2
- data/lib/maybe_so/core_ext/string.rb +0 -2
- data/lib/maybe_so/core_ext/true_class.rb +0 -2
- data/lib/maybe_so/version.rb +1 -1
- data/spec/{fixnum_spec.rb → integer_spec.rb} +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a9d340ec26474b799607716977f7a68b141a90d
|
4
|
+
data.tar.gz: cb9d30400f642c1e36f2336824342ee5083899ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 325cc9c084c81d68641533abdf62e64f6ba55f57acca5a70f5d6d1982a39e48ffb202816c4ef0a2ea34c189840263940faef348c6433895ddcb52e4a25ddacec
|
7
|
+
data.tar.gz: 07a1dc439450bfa782d922655f8ad7c8dccb4972d13e44ba61168c20b600b7678a14376e8e97fe982762ca09301fcf7dda2470d81540cb6be8faab06cb3467b0
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Ever get annoyed that ActiveRecord blows up if you set a boolean column to nil?
|
|
4
4
|
|
5
5
|
Maybe So handles this for you!
|
6
6
|
|
7
|
-
Tested on
|
7
|
+
Tested on Ruby 2.x (MRI)
|
8
8
|
|
9
9
|
[![Build Status](https://secure.travis-ci.org/ministrycentered/maybe_so.svg?branch=master)](http://travis-ci.org/ministrycentered/maybe_so)
|
10
10
|
|
@@ -61,7 +61,7 @@ end
|
|
61
61
|
`boolean_attributes` accepts an options hash for the following:
|
62
62
|
|
63
63
|
- `truthy_values`: array of values (will be coerced into strings when checking) to be considered truthy
|
64
|
-
- `skip_validator`: this will
|
64
|
+
- `skip_validator`: this will _omit_ adding the `validates_inclusion_of` to ensure records are not valid unless they are set to `true` or `false`. Note it does _not_ validate presence. If you want that, you'll need to add a separate validation.
|
65
65
|
|
66
66
|
Example custom configuration:
|
67
67
|
|
@@ -71,6 +71,36 @@ class Product < ActiveRecord::Base
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
+
### #to_bool
|
75
|
+
|
76
|
+
`String`, `Integer`, `TrueClass`, `FalseClass`, `NilClass` all have `#to_bool` added.
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
"Yes".to_bool # Uses the same truthy values as shown above
|
80
|
+
# => true
|
81
|
+
|
82
|
+
"zing".to_bool
|
83
|
+
# => false
|
84
|
+
|
85
|
+
"1".to_bool
|
86
|
+
# => true
|
87
|
+
|
88
|
+
1.to_bool
|
89
|
+
# => true
|
90
|
+
|
91
|
+
42.to_bool
|
92
|
+
# => false
|
93
|
+
|
94
|
+
true.to_bool
|
95
|
+
# => true
|
96
|
+
|
97
|
+
false.to_bool
|
98
|
+
# => false
|
99
|
+
|
100
|
+
nil.to_bool
|
101
|
+
# => false
|
102
|
+
```
|
103
|
+
|
74
104
|
## Copyright
|
75
105
|
|
76
|
-
Copyright (c)
|
106
|
+
Copyright (c) 2017 James Miller and Tanner Mares
|
@@ -9,7 +9,8 @@ module ActiveModel
|
|
9
9
|
include MaybeSo::ActiveModel::BooleanAttribute
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
alias_method :included_without_boolean_attribute, :included
|
13
|
+
alias_method :included, :included_with_boolean_attribute
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
data/lib/maybe_so/core_ext.rb
CHANGED
data/lib/maybe_so/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maybe_so
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Miller
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -89,6 +89,7 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
91
|
- ".travis.yml"
|
92
|
+
- CHANGELOG.md
|
92
93
|
- Gemfile
|
93
94
|
- LICENSE.txt
|
94
95
|
- README.md
|
@@ -98,7 +99,7 @@ files:
|
|
98
99
|
- lib/maybe_so/active_model/boolean_attribute.rb
|
99
100
|
- lib/maybe_so/core_ext.rb
|
100
101
|
- lib/maybe_so/core_ext/false_class.rb
|
101
|
-
- lib/maybe_so/core_ext/
|
102
|
+
- lib/maybe_so/core_ext/integer.rb
|
102
103
|
- lib/maybe_so/core_ext/nil_class.rb
|
103
104
|
- lib/maybe_so/core_ext/string.rb
|
104
105
|
- lib/maybe_so/core_ext/true_class.rb
|
@@ -106,7 +107,7 @@ files:
|
|
106
107
|
- maybe_so.gemspec
|
107
108
|
- spec/boolean_attribute_spec.rb
|
108
109
|
- spec/false_class_spec.rb
|
109
|
-
- spec/
|
110
|
+
- spec/integer_spec.rb
|
110
111
|
- spec/nil_class_spec.rb
|
111
112
|
- spec/spec_helper.rb
|
112
113
|
- spec/string_spec.rb
|
@@ -131,14 +132,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
132
|
version: '0'
|
132
133
|
requirements: []
|
133
134
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.6.10
|
135
136
|
signing_key:
|
136
137
|
specification_version: 4
|
137
138
|
summary: Ruby boolean type casting
|
138
139
|
test_files:
|
139
140
|
- spec/boolean_attribute_spec.rb
|
140
141
|
- spec/false_class_spec.rb
|
141
|
-
- spec/
|
142
|
+
- spec/integer_spec.rb
|
142
143
|
- spec/nil_class_spec.rb
|
143
144
|
- spec/spec_helper.rb
|
144
145
|
- spec/string_spec.rb
|