model_attribute 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +6 -3
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -0
- data/README.md +14 -1
- data/lib/model_attribute/casts.rb +2 -2
- data/lib/model_attribute/version.rb +1 -1
- data/model_attribute.gemspec +0 -3
- data/spec/model_attributes_spec.rb +10 -0
- metadata +3 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50352c846ab8e95216a97c8bb1f75e98e700efcc
|
4
|
+
data.tar.gz: 7db758d0a583b823627949a64ce766a9555a8152
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1126078dd83bc04a5e92c32e397d940458195c68062a17ebeb366670cd56cbe7ecae791efd081d3a1e01a8a1b00725936a02e62813dbb804e1b723609f100f0d
|
7
|
+
data.tar.gz: 46dacb941d9bc0a72ca982fa8f7001a73ac3413e878f07346e2465be7d6e0b874f9922e792e1cc77b13b04c796946594e433aedceb082841e1cfafd1b8283f15
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## 3.1.0
|
6
|
+
|
7
|
+
- Allow strings 'true' and 'false' to be assigned to boolean attributes and be
|
8
|
+
cast as expected.
|
9
|
+
|
5
10
|
## 3.0.0
|
6
11
|
|
7
12
|
- **Breaking change**: All casting errors raise `ArgumentError`. Previously some
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# ModelAttribute [![Build Status](https://travis-ci.org/yammer/model_attribute.svg?branch=master)](https://travis-ci.org/yammer/model_attribute)
|
1
|
+
# ModelAttribute [![Gem Version](https://badge.fury.io/rb/model_attribute.svg)](http://badge.fury.io/rb/model_attribute) [![Build Status](https://travis-ci.org/yammer/model_attribute.svg?branch=master)](https://travis-ci.org/yammer/model_attribute)
|
2
2
|
|
3
3
|
Simple attributes for a non-ActiveRecord model.
|
4
4
|
|
@@ -75,6 +75,10 @@ user.paid = 'f'
|
|
75
75
|
user.paid # => false
|
76
76
|
user.paid = 't'
|
77
77
|
user.paid # => true
|
78
|
+
user.paid = 'false'
|
79
|
+
user.paid # => false
|
80
|
+
user.paid = 'true'
|
81
|
+
user.paid # => true
|
78
82
|
|
79
83
|
# A :time attribute
|
80
84
|
user.created_at = Time.now
|
@@ -215,3 +219,12 @@ Or install it yourself as:
|
|
215
219
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
216
220
|
4. Push to the branch (`git push origin my-new-feature`)
|
217
221
|
5. Create a new Pull Request
|
222
|
+
|
223
|
+
## Code of Conduct
|
224
|
+
|
225
|
+
This project has adopted the [Microsoft Open Source Code of
|
226
|
+
Conduct](https://opensource.microsoft.com/codeofconduct/). For more information
|
227
|
+
see the [Code of Conduct
|
228
|
+
FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact
|
229
|
+
[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional
|
230
|
+
questions or comments.
|
@@ -13,9 +13,9 @@ module ModelAttribute
|
|
13
13
|
when :boolean
|
14
14
|
if !!value == value
|
15
15
|
value
|
16
|
-
elsif value == 't'
|
16
|
+
elsif value == 't' || value == 'true'
|
17
17
|
true
|
18
|
-
elsif value == 'f'
|
18
|
+
elsif value == 'f' || value == 'false'
|
19
19
|
false
|
20
20
|
else
|
21
21
|
raise ArgumentError, "Can't cast #{value.inspect} to boolean"
|
data/model_attribute.gemspec
CHANGED
@@ -24,7 +24,4 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.7"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.1"
|
27
|
-
spec.add_development_dependency "rspec-nc", "~> 0.2"
|
28
|
-
spec.add_development_dependency "guard", "~> 2.8"
|
29
|
-
spec.add_development_dependency "guard-rspec", "~> 4.3"
|
30
27
|
end
|
@@ -119,6 +119,16 @@ RSpec.describe "a class using ModelAttribute" do
|
|
119
119
|
expect(user.paid).to eq(false)
|
120
120
|
end
|
121
121
|
|
122
|
+
it "parses 'false' to false" do
|
123
|
+
user.paid = 'false'
|
124
|
+
expect(user.paid).to eq(false)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "parses 'true' to true" do
|
128
|
+
user.paid = 'true'
|
129
|
+
expect(user.paid).to eq(true)
|
130
|
+
end
|
131
|
+
|
122
132
|
it "raises if passed a string it can't parse" do
|
123
133
|
expect { user.paid = '3a' }.to raise_error(ArgumentError,
|
124
134
|
'Can\'t cast "3a" to boolean')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Waller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,48 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec-nc
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.2'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.2'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: guard
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '2.8'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '2.8'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: guard-rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '4.3'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '4.3'
|
97
55
|
description: |2
|
98
56
|
Attributes for non-ActiveRecord models.
|
99
57
|
Smaller and simpler than Virtus, and adds dirty tracking.
|
@@ -140,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
98
|
version: '0'
|
141
99
|
requirements: []
|
142
100
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
101
|
+
rubygems_version: 2.5.1
|
144
102
|
signing_key:
|
145
103
|
specification_version: 4
|
146
104
|
summary: Attributes for non-ActiveRecord models
|