typed-store 0.1.0 → 0.2.0
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.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/lib/typed-store.rb +4 -0
- data/test/test_typed-store.rb +22 -0
- data/typed-store.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGQ5N2EyNjljZTZjMTViZmNlYjEwOTAzNzY4ZGJhMTdjYWQ5ZTEzNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWJmMzQxY2Q2ZGYyNjJjZjEzYzFjZmY1ZDcxMzMyN2UxMDI0NmYzMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmRhY2Y3YTQyMzhmNjgwYjZhOGZlOTY0MTZhNDRiNWIyYmIyMDJlNjY5OTg3
|
10
|
+
ZjAwMGUyYjQ5MjM5Y2QyMjE4ODdhODMzNWY1YWEwN2QzOGZmOWM0ZGMxMTE0
|
11
|
+
NGJhZDEwNmZhMmFjYTQxYTJkNDM0YjhjZjYzOTllNjJkYzU5NGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2RmNThkMjFiYTNmNDAyNzhkNDJmNGZlNTIwOTNkY2M4ZDMyZDliYjg5NmY0
|
14
|
+
YTQzM2Y0NWQwZDc5OTMxYmQwZTg4MzU5M2NkMjUyOTk1NTA4ZmE3YzM1ZjJl
|
15
|
+
YTk1ZTI2Y2FlZDhkYmRmMDg4ZjU3ODkwMTFiNWFjMzliNDE1ZDg=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
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
|
data/test/test_typed-store.rb
CHANGED
@@ -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.
|
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.
|
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-
|
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.
|
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-
|
11
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|