virtus 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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..master](https://github.com/solnic/virtus/compare/v0.4.2...master)
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Piotr Solnica
1
+ Copyright (c) 2011-2012 Piotr Solnica
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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.attribute_set # => { :name => "Piotr", :age => 28 }
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 With Modules
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
@@ -8,7 +8,9 @@ module Virtus
8
8
 
9
9
  # @api private
10
10
  def coerce(attributes)
11
- super or @primitive.new(attributes)
11
+ unless attributes.nil?
12
+ super or @primitive.new(attributes)
13
+ end
12
14
  end
13
15
 
14
16
  end # class FromOpenStruct
@@ -8,7 +8,9 @@ module Virtus
8
8
 
9
9
  # @api private
10
10
  def coerce(attributes)
11
- super or @primitive.new(*attributes)
11
+ unless attributes.nil?
12
+ super or @primitive.new(*attributes)
13
+ end
12
14
  end
13
15
 
14
16
  end # class FromStruct
@@ -1,3 +1,3 @@
1
1
  module Virtus
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
@@ -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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
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-08 00:00:00 Z
18
+ date: 2012-06-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: backports