redis_object 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2RlY2YxYmY1ZWY0ZWFlODA1ZTg0MWM3ZDhmYWFjNmU0MWY1ZWM5Yw==
4
+ OGRkODFlNTE1NmI1NDI0Njc0MjQxMzlmNTFiOTA0MGViZWMzYWNjMQ==
5
5
  data.tar.gz: !binary |-
6
- NTBjOTBmYTgyNTc2NTc3NzU5MTRlOWQ3NWQ3NTI4MTM1YTViZWUxYg==
6
+ MDdhZDJiZmZkYWZjNzg2ZmIxOGY0NDFjNjRkY2RkOTIzMDZhYTQwOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTdiN2Q1NjRjNDUzMjgxMjA0ZGIwYjQwMDUxYmJkYWZlODlhNWQyZWQyODk4
10
- ODhhZDA2Y2I3MzQ4ZjVhZWIxMGUyYTY1YWMzNzViZjZmZDcxMmUyNGZhZjkw
11
- NWRkYjJiMmFkNWZhZWFhN2FmNDRhNTNiNGYyOTFmZTQ4ZjNjZDk=
9
+ YzE0YWQxNjYxNjM4YjExNTAwNjZiMzM5OTliNzkyYTljYTRjYjAzMTMyOTg3
10
+ M2JkOTBlMThhZGVjNDM5ZjA5NjFmMWY1NTkzMDAyNTkxMzFhYzJmNjhhNGJk
11
+ YTk3Yjk1YzY0MzRiMWRmOTQ5ZDdjMGVmMThkNmMwMmI1Nzk5NzE=
12
12
  data.tar.gz: !binary |-
13
- MzY5ODIzOGJkMWFiMTVhOGVlNGMzY2MxYWRkMDUzYzJhZTI1NmQxNTM2YTQz
14
- ODRlNjg5Yjg4NGI0MTlkMDRhYTUzNGI3ODg5MGE3Yzc3MDM5YWMyNDYyYWVm
15
- ZDY2YzQzOTI1NjdmODE1YmU4YjBhNjc1MjY0MWVlYzgyMDU3NmQ=
13
+ YzRhNjY2MjEzYzQ3MjY5OTAxYzcxYjU1MzA5ZmQ4ZGVkNTRlMGU0ZTgxOWIy
14
+ ZGY5NWNlZTQxNGJhYzFlZTkwYmE2ZTU0MGExYWU4ZDFjODdmYjI1ZGVjYzYx
15
+ YzU1NzdhYTI2NzA1MDNkNTZkYTIzMDFiMGU5YTQ2ODc0ZDRhZTE=
@@ -3,7 +3,7 @@ module Seabright
3
3
  module ArrayType
4
4
 
5
5
  def format_array(val)
6
- Yajl::Parser.new(:symbolize_keys => true).parse(val)
6
+ val ? Yajl::Parser.new(:symbolize_keys => true).parse(val) : []
7
7
  end
8
8
 
9
9
  def save_array(val)
@@ -3,7 +3,7 @@ module Seabright
3
3
  module FloatType
4
4
 
5
5
  def format_float(val)
6
- Float(val)
6
+ val ? Float(val) : nil
7
7
  end
8
8
  alias_method :score_float, :format_float
9
9
 
@@ -3,7 +3,7 @@ module Seabright
3
3
  module JsonType
4
4
 
5
5
  def format_json(val)
6
- Yajl::Parser.new(:symbolize_keys => true).parse(val || "")
6
+ val ? Yajl::Parser.new(:symbolize_keys => true).parse(val) : nil
7
7
  end
8
8
 
9
9
  def save_json(val)
@@ -3,11 +3,11 @@ module Seabright
3
3
  module NumberType
4
4
 
5
5
  def format_number(val)
6
- val.to_i
6
+ val ? val.to_i : nil
7
7
  end
8
8
 
9
9
  def score_number(val)
10
- Float(val)
10
+ Float(val || 0.0)
11
11
  end
12
12
 
13
13
  end
@@ -1,5 +1,5 @@
1
1
  module Seabright
2
2
  class RedisObject
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.2"
4
4
  end
5
5
  end
data/spec/types_spec.rb CHANGED
@@ -16,9 +16,9 @@ module TypeSpec
16
16
  TestData = TestValues.inject({}){|acc,(k,v)| acc["a_#{k}".to_sym] = v; acc }
17
17
 
18
18
  class TypedObject < RedisObject
19
- json :another_json
20
19
  TestValues.keys.each do |type|
21
20
  send(type.to_sym,"a_#{type}".to_sym)
21
+ send(type.to_sym,"another_#{type}".to_sym)
22
22
  end
23
23
  end
24
24
 
@@ -90,11 +90,19 @@ module TypeSpec
90
90
 
91
91
  end
92
92
 
93
- it "can get unset json field" do
93
+ it "can get unset typed fields" do
94
94
 
95
95
  obj = TypedObject.new
96
96
 
97
97
  obj.another_json.should eq(nil)
98
+ obj.another_array.should be_a(Array)
99
+ obj.another_array.size.should eq(0)
100
+ obj.another_date.should eq(nil)
101
+ obj.another_int.should eq(nil)
102
+ obj.another_number.should eq(nil)
103
+ obj.another_float.should eq(nil)
104
+ obj.another_bool.should eq(false)
105
+ obj.another_boolean.should eq(false)
98
106
 
99
107
  end
100
108
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Bragg