dm-types 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.9.9 / 2009-01-04
2
+
3
+ * 1 bug fix:
4
+
5
+ * Updated DM::Json.typecast to handle nil values
6
+
1
7
  === 0.9.8 / 2008-12-07
2
8
 
3
9
  * 2 bug fixes:
data/lib/dm-types.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'rubygems'
3
3
 
4
- gem 'dm-core', '~>0.9.8'
4
+ gem 'dm-core', '~>0.9.9'
5
5
  require 'dm-core'
6
6
 
7
7
  module DataMapper
data/lib/dm-types/enum.rb CHANGED
@@ -34,8 +34,8 @@ module DataMapper
34
34
 
35
35
  def self.dump(value, property)
36
36
  case value
37
- when Array then value.collect { |v| self.dump(v, property) }
38
- else self.flag_map.invert[value]
37
+ when Array then value.collect { |v| self.dump(v, property) }
38
+ else self.flag_map.invert[value]
39
39
  end
40
40
  end
41
41
 
@@ -46,7 +46,7 @@ module DataMapper
46
46
  when Symbol then value.to_sym
47
47
  when String then value.to_s
48
48
  when Fixnum then value.to_i
49
- else value
49
+ else value
50
50
  end
51
51
  end
52
52
  end # class Enum
@@ -61,7 +61,7 @@ module DataMapper
61
61
  return unless property.options[:auto_validation]
62
62
 
63
63
  if property.type.ancestors.include?(Types::Enum)
64
- validates_within property.name, options_with_message({:set => property.type.flag_map.values}, property, :within)
64
+ validates_within property.name, options_with_message({:set => property.type.flag_map.values}, property, :within)
65
65
  end
66
66
  end
67
67
  end
data/lib/dm-types/json.rb CHANGED
@@ -13,14 +13,12 @@ module DataMapper
13
13
  elsif value.is_a?(String)
14
14
  ::JSON.load(value)
15
15
  else
16
- raise ArgumentError.new("+value+ must be nil or a String")
16
+ raise ArgumentError, '+value+ must be nil or a String'
17
17
  end
18
18
  end
19
19
 
20
20
  def self.dump(value, property)
21
- if value.nil?
22
- nil
23
- elsif value.is_a?(String)
21
+ if value.nil? || value.is_a?(String)
24
22
  value
25
23
  else
26
24
  ::JSON.dump(value)
@@ -28,8 +26,7 @@ module DataMapper
28
26
  end
29
27
 
30
28
  def self.typecast(value, property)
31
- # Arrays and hashes are left alone, while strings are parsed as JSON.
32
- if value.kind_of?(Array) || value.kind_of?(Hash)
29
+ if value.nil? || value.kind_of?(Array) || value.kind_of?(Hash)
33
30
  value
34
31
  else
35
32
  ::JSON.load(value.to_s)
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Types
3
- VERSION = '0.9.8'
3
+ VERSION = '0.9.9'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-types
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Smoot
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-07 00:00:00 -08:00
12
+ date: 2009-01-04 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.8
23
+ version: 0.9.9
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: addressable