simple_enum 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/simple_enum/accessors/accessor.rb +2 -2
- data/lib/simple_enum/version.rb +1 -1
- data/spec/simple_enum/accessors_spec.rb +14 -0
- 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: 15a4d23ebb4c06389cc6567924cd06fdf9120534
|
4
|
+
data.tar.gz: 7ae02ee44339aa33f7b2f2e4b80818e5c07b0afe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3a157e56f6876c9e62e567fd39b13c30cd1b5a52242eea88eaf4b696119b41f061392792371a3bde550478f4d7cc55eef4041b4128656bdf040cb5d3fcba4b9
|
7
|
+
data.tar.gz: 9285798a1feee8f685154a4135d9644fe94ef7ef3911ff863f9305e80fffeaee7217b2a46a614c07f364deed8391cd6ac0c5b94c34e649f9e66118b5d9d58e3c
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -50,7 +50,7 @@ to use simple_enum with another version of mongoid, use version 1.6 instead.
|
|
50
50
|
Load mongoid support in the `Gemfile`:
|
51
51
|
|
52
52
|
```ruby
|
53
|
-
gem 'simple_enum', '2.0.0
|
53
|
+
gem 'simple_enum', '~> 2.0.0' , require: 'simple_enum/mongoid'
|
54
54
|
```
|
55
55
|
|
56
56
|
Add this to a model:
|
@@ -29,11 +29,11 @@ module SimpleEnum
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def changed?(object)
|
32
|
-
object.attribute_changed
|
32
|
+
object.send(:attribute_changed?, source)
|
33
33
|
end
|
34
34
|
|
35
35
|
def was(object)
|
36
|
-
enum.key(object.attribute_was
|
36
|
+
enum.key(object.send(:attribute_was, source))
|
37
37
|
end
|
38
38
|
|
39
39
|
def to_s
|
data/lib/simple_enum/version.rb
CHANGED
@@ -159,6 +159,20 @@ describe SimpleEnum::Accessors do
|
|
159
159
|
expect(object).to receive(:attribute_was).with('gender_cd') { 1 }
|
160
160
|
expect(subject.was(object)).to eq :female
|
161
161
|
end
|
162
|
+
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context 'dirty attributes on ActiveModel', active_record: true do
|
167
|
+
fake_active_record(:klass) { as_enum :gender, %w{male female} }
|
168
|
+
let(:object) { klass.create(gender: :male) }
|
169
|
+
|
170
|
+
it 'does not raise error "private method attribute_was called"' do
|
171
|
+
object.gender = :female
|
172
|
+
expect do
|
173
|
+
expect(object.gender_changed?).to be_true
|
174
|
+
expect(object.gender_was).to eq :male
|
175
|
+
end.to_not raise_error
|
162
176
|
end
|
163
177
|
end
|
164
178
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Westermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|