record_store 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/record_store.rb +19 -6
- data/record_store.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6555a4d5c8d65ea81e0341babdac09eba1c2df7
|
4
|
+
data.tar.gz: d1a73ddb5660a5b4e7a0dd157b632b5c6325dfb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeb5548e87bd8d592d39254d18a6b19a2e56e69a8680320f240881dac8645503ed1561c39c7df4ae0ed97bb72d32e7348bfc81e3f796f26f0ae8b07014286c8e
|
7
|
+
data.tar.gz: 62f9e83f0a8cbc56b1923d0c8a4047712cff41eaf1d6bb8103f490f8c1307e9deb642f566100672a38bad87626bcc15d9a5038ef28caa550b08cf4d1dc8b810f
|
data/README.md
CHANGED
data/lib/record_store.rb
CHANGED
@@ -1,16 +1,29 @@
|
|
1
1
|
class RecordStore
|
2
|
-
VERSION = "0.
|
2
|
+
VERSION = "0.3.0"
|
3
3
|
|
4
4
|
class << self
|
5
|
-
def
|
6
|
-
|
5
|
+
def database
|
6
|
+
raise "You must setup your database"
|
7
7
|
end
|
8
|
-
alias_method :<<, :put
|
9
8
|
|
10
9
|
def dataset_name
|
11
10
|
@dataset_name ||= name.sub(/Store$/,'').tableize.to_sym
|
12
11
|
end
|
13
12
|
|
13
|
+
def dataset
|
14
|
+
database[dataset_name]
|
15
|
+
end
|
16
|
+
|
17
|
+
def get(id)
|
18
|
+
dataset.where(id: id).first
|
19
|
+
end
|
20
|
+
alias_method :[], :get
|
21
|
+
|
22
|
+
def put(record)
|
23
|
+
new(record).put
|
24
|
+
end
|
25
|
+
alias_method :<<, :put
|
26
|
+
|
14
27
|
def type_column_map(database)
|
15
28
|
@type_column_map ||= database.schema(dataset_name).each_with_object({}) do |(column,metadata),map|
|
16
29
|
map[metadata[:db_type]] ||= []
|
@@ -65,11 +78,11 @@ class RecordStore
|
|
65
78
|
end
|
66
79
|
|
67
80
|
def database
|
68
|
-
|
81
|
+
self.class.database
|
69
82
|
end
|
70
83
|
|
71
84
|
def dataset
|
72
|
-
|
85
|
+
self.class.dataset
|
73
86
|
end
|
74
87
|
|
75
88
|
def errors
|
data/record_store.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|