virtus 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog.md +7 -1
- data/LICENSE +1 -1
- data/README.md +6 -3
- data/lib/virtus/attribute/embedded_value/from_open_struct.rb +3 -1
- data/lib/virtus/attribute/embedded_value/from_struct.rb +3 -1
- data/lib/virtus/version.rb +1 -1
- data/spec/unit/virtus/attribute/embedded_value/from_open_struct/coerce_spec.rb +6 -0
- data/spec/unit/virtus/attribute/embedded_value/from_struct/coerce_spec.rb +6 -0
- metadata +4 -4
data/Changelog.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# v0.5.1 2012-06-11
|
2
|
+
|
3
|
+
* [fixed] EV properly handle nil as the value (solnic)
|
4
|
+
|
5
|
+
[Compare v0.5.0..v0.5.1](https://github.com/solnic/virtus/compare/v0.5.0...v0.5.1)
|
6
|
+
|
1
7
|
# v0.5.0 2012-06-08
|
2
8
|
|
3
9
|
* [feature] Support for extending objects (solnic)
|
@@ -6,7 +12,7 @@
|
|
6
12
|
* [changed] Allow any input for EmbeddedValue and ValueObject constructors (solnic)
|
7
13
|
* [changed] ValueObject instances cannot be duped or cloned (senny)
|
8
14
|
|
9
|
-
[Compare v0.4.2..
|
15
|
+
[Compare v0.4.2..v0.5.0](https://github.com/solnic/virtus/compare/v0.4.2...v0.5.0)
|
10
16
|
|
11
17
|
# v0.4.2 2012-05-08
|
12
18
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -30,6 +30,9 @@ gem 'virtus'
|
|
30
30
|
Examples
|
31
31
|
--------
|
32
32
|
|
33
|
+
### Using Virtus with Classes
|
34
|
+
|
35
|
+
You can create classes extended with virtus and define attributes:
|
33
36
|
|
34
37
|
``` ruby
|
35
38
|
class User
|
@@ -41,7 +44,7 @@ class User
|
|
41
44
|
end
|
42
45
|
|
43
46
|
user = User.new(:name => 'Piotr', :age => 28)
|
44
|
-
user.
|
47
|
+
user.attributes # => { :name => "Piotr", :age => 28 }
|
45
48
|
|
46
49
|
user.name # => "Piotr"
|
47
50
|
|
@@ -51,7 +54,7 @@ user.age.class # => Fixnum
|
|
51
54
|
user.birthday = 'November 18th, 1983' # => #<DateTime: 1983-11-18T00:00:00+00:00 (4891313/2,0/1,2299161)>
|
52
55
|
```
|
53
56
|
|
54
|
-
### Using Virtus
|
57
|
+
### Using Virtus with Modules
|
55
58
|
|
56
59
|
You can create modules extended with virtus and define attributes for later
|
57
60
|
inclusion in your classes:
|
@@ -330,7 +333,7 @@ Contributing
|
|
330
333
|
License
|
331
334
|
-------
|
332
335
|
|
333
|
-
Copyright (c) 2011 Piotr Solnica
|
336
|
+
Copyright (c) 2011-2012 Piotr Solnica
|
334
337
|
|
335
338
|
Permission is hereby granted, free of charge, to any person obtaining
|
336
339
|
a copy of this software and associated documentation files (the
|
data/lib/virtus/version.rb
CHANGED
@@ -9,6 +9,12 @@ describe Virtus::Attribute::EmbeddedValue::FromOpenStruct, '#coerce' do
|
|
9
9
|
described_class.new(:name, :primitive => primitive)
|
10
10
|
end
|
11
11
|
|
12
|
+
context 'when the value is nil' do
|
13
|
+
let(:value) { nil }
|
14
|
+
|
15
|
+
it { should be_nil }
|
16
|
+
end
|
17
|
+
|
12
18
|
context 'when the value is a primitive instance' do
|
13
19
|
let(:value) { primitive.new }
|
14
20
|
|
@@ -9,6 +9,12 @@ describe Virtus::Attribute::EmbeddedValue::FromStruct, '#coerce' do
|
|
9
9
|
described_class.new(:name, :primitive => primitive)
|
10
10
|
end
|
11
11
|
|
12
|
+
context 'when the value is nil' do
|
13
|
+
let(:value) { nil }
|
14
|
+
|
15
|
+
it { should be_nil }
|
16
|
+
end
|
17
|
+
|
12
18
|
context 'when the value is a primitive instance' do
|
13
19
|
let(:value) { primitive.new }
|
14
20
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virtus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Piotr Solnica
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-06-
|
18
|
+
date: 2012-06-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: backports
|