typed-store 0.1.0 → 0.2.0

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
- MzBmZGM0ZDIzNGU2YmNkMWRmMDRkYWE5Y2NmYjdjMGMwYTZhM2ExYQ==
4
+ ZGQ5N2EyNjljZTZjMTViZmNlYjEwOTAzNzY4ZGJhMTdjYWQ5ZTEzNw==
5
5
  data.tar.gz: !binary |-
6
- NGQ2MDI3NDk4YjU0OWY5NDU3Y2VlZTZjZDg0NjAxZGI4M2YzMWRkNQ==
6
+ NWJmMzQxY2Q2ZGYyNjJjZjEzYzFjZmY1ZDcxMzMyN2UxMDI0NmYzMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MmExNWRmYmNjNWZhYzY5MWM2ZDhjOTI0MTczYmY3ZjhhN2JmMzMxMWM5NDE1
10
- NzU3NTdlMTM1NzFlZGMzNDQ2YWNiNTA0MTEyNmM5MDBlNTNiYzhkMmJjMzVh
11
- OGZjODlhOTJhY2Y2ZTFlZmQ1YWYyMmE4MmI0NmVhMGE3MDJlZGY=
9
+ YmRhY2Y3YTQyMzhmNjgwYjZhOGZlOTY0MTZhNDRiNWIyYmIyMDJlNjY5OTg3
10
+ ZjAwMGUyYjQ5MjM5Y2QyMjE4ODdhODMzNWY1YWEwN2QzOGZmOWM0ZGMxMTE0
11
+ NGJhZDEwNmZhMmFjYTQxYTJkNDM0YjhjZjYzOTllNjJkYzU5NGU=
12
12
  data.tar.gz: !binary |-
13
- YTdhZjM3YWQxYWQ1MmRiMjBkZmQ3M2FkZDI0YjJhNmFjNjE2YWQ5NzViNjVj
14
- NjRkZjFiN2U3ODEwYzM3OWFhN2NmN2ZmYzc4NWUyOThkMTExMWM1NzZjZjVm
15
- ZTQwMWJiNGViYmUzNGJkNTA3OWI4ZGZiNDYxN2U0Y2RkYTQyZTY=
13
+ N2RmNThkMjFiYTNmNDAyNzhkNDJmNGZlNTIwOTNkY2M4ZDMyZDliYjg5NmY0
14
+ YTQzM2Y0NWQwZDc5OTMxYmQwZTg4MzU5M2NkMjUyOTk1NTA4ZmE3YzM1ZjJl
15
+ YTk1ZTI2Y2FlZDhkYmRmMDg4ZjU3ODkwMTFiNWFjMzliNDE1ZDg=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/typed-store.rb CHANGED
@@ -10,6 +10,10 @@ module TypedStore
10
10
  mappings.each do |mapping|
11
11
  key, type = *mapping.first
12
12
 
13
+ define_method "#{key}=" do |value|
14
+ write_store_attribute(store_attribute, key, value ? value.to_s : nil)
15
+ end
16
+
13
17
  define_method key do
14
18
  value = read_store_attribute(store_attribute, key)
15
19
  return nil unless value
@@ -53,6 +53,28 @@ class TestTypedStore < Test::Unit::TestCase
53
53
  assert_equal(datetime.to_s, subject.a_datetime.to_s)
54
54
  end
55
55
 
56
+ should "cast things when set, so they are readable before saving" do
57
+ subject = TestClass.new
58
+
59
+ time = Time.now
60
+ date = Date.today
61
+ datetime = DateTime.now
62
+
63
+ subject.a_str = "this is a test"
64
+ subject.a_int = 12452
65
+ subject.a_dbl = 3.33333335
66
+ subject.a_time = time
67
+ subject.a_date = date
68
+ subject.a_datetime = datetime
69
+
70
+ assert_equal("this is a test", subject.a_str)
71
+ assert_equal(12452, subject.a_int)
72
+ assert_equal(3.33333335, subject.a_dbl)
73
+ assert_equal(time.to_s, subject.a_time.to_s)
74
+ assert_equal(date.to_s, subject.a_date.to_s)
75
+ assert_equal(datetime.to_s, subject.a_datetime.to_s)
76
+ end
77
+
56
78
  should "let you set and get nils" do
57
79
  subject = TestClass.new
58
80
 
data/typed-store.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: typed-store 0.1.0 ruby lib
5
+ # stub: typed-store 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "typed-store"
9
- s.version = "0.1.0"
9
+ s.version = "0.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Michael Baldry"]
14
- s.date = "2014-03-25"
14
+ s.date = "2014-03-26"
15
15
  s.description = "As Postgres HStore column doesn't store types, when you use this in conjuection with store_accessor, it always returns things as strings. This tidies that up."
16
16
  s.email = "michael@brightbits.co.uk"
17
17
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typed-store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Baldry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-25 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord