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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f98dc3b3a7439e904f88b8d46856b689d40cd40
4
- data.tar.gz: 584c3e8614f3fac484414838d5ae2c5c9c114053
3
+ metadata.gz: d6555a4d5c8d65ea81e0341babdac09eba1c2df7
4
+ data.tar.gz: d1a73ddb5660a5b4e7a0dd157b632b5c6325dfb7
5
5
  SHA512:
6
- metadata.gz: c94aca9cdbcb23e70d49e5c7ca643ddbc987ece4caf556ced296a0c3eea0ffbd736ce35248517a4c97a17ce8a9b8ae1dec6951ac5b8b3ff5e569635cab7869e8
7
- data.tar.gz: 15509f73d2a7881364f98674cb0b73e736a966a02cc69ea446cd3614280429edeb9bd9a8417fa544d18a8d6972516f3422c74d3f478301d8076a16c96a11bd54
6
+ metadata.gz: eeb5548e87bd8d592d39254d18a6b19a2e56e69a8680320f240881dac8645503ed1561c39c7df4ae0ed97bb72d32e7348bfc81e3f796f26f0ae8b07014286c8e
7
+ data.tar.gz: 62f9e83f0a8cbc56b1923d0c8a4047712cff41eaf1d6bb8103f490f8c1307e9deb642f566100672a38bad87626bcc15d9a5038ef28caa550b08cf4d1dc8b810f
data/README.md CHANGED
@@ -24,7 +24,7 @@ If you have an application where you are working with records as hashes and you
24
24
 
25
25
  ```ruby
26
26
  class Store < RecordStore
27
- def database
27
+ def self.database
28
28
  DB
29
29
  end
30
30
  end
data/lib/record_store.rb CHANGED
@@ -1,16 +1,29 @@
1
1
  class RecordStore
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
 
4
4
  class << self
5
- def put(record)
6
- new(record).put
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
- raise "You must setup your database"
81
+ self.class.database
69
82
  end
70
83
 
71
84
  def dataset
72
- database[self.class.dataset_name]
85
+ self.class.dataset
73
86
  end
74
87
 
75
88
  def errors
data/record_store.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "record_store"
5
- spec.version = "0.2.0"
5
+ spec.version = "0.3.0"
6
6
  spec.authors = ["Paul Barry"]
7
7
  spec.email = ["mail@paulbarry.com"]
8
8
 
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.2.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-07-31 00:00:00.000000000 Z
11
+ date: 2015-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler