hold 1.0.1 → 1.0.2
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 +4 -4
- data/README.md +2 -1
- data/lib/hold/serialized.rb +7 -5
- data/lib/hold/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccf3c450bd0581651f077eba61da713f1d1d2c55
|
4
|
+
data.tar.gz: 9c91f6779ba78610c0cbf5140f1c401994b04f6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9264703012fd325bf2dacd390aa732830dbb6874c2da1cf05a774a15a8424ff300f46c268a6351f983cd9af29a79ccf8851407c8e358dab3b27f4eb74322dc3
|
7
|
+
data.tar.gz: fbf1e4cb8abfd62aad061b5e5675f251e30e2a6d357c8da5e31c021a56d9624c6eeecdf2bf47976512d815fba8f458a1fe67684eefd1c1ea4fa2303a1acad52d
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-

|
1
|
+
[](https://travis-ci.org/mediasp/hold)
|
2
|
+
[](http://badge.fury.io/rb/hold)
|
2
3
|
# Hold
|
3
4
|
|
4
5
|
A ruby library geared towards separating persistence concerns from data model classes.
|
data/lib/hold/serialized.rb
CHANGED
@@ -86,10 +86,13 @@ module Hold
|
|
86
86
|
|
87
87
|
def get_by_id(id)
|
88
88
|
json = @cache.get_with_key(cache_key(id))
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
if json
|
90
|
+
string_hash = @serializer.deserialize(json)
|
91
|
+
string_hash.inject({}) do |memo, (k,v)|
|
92
|
+
memo[k.to_sym] = v
|
93
|
+
memo
|
94
|
+
end
|
95
|
+
end
|
93
96
|
end
|
94
97
|
|
95
98
|
def delete_id(id)
|
@@ -99,6 +102,5 @@ module Hold
|
|
99
102
|
def contains_id?(id)
|
100
103
|
@cache.has_key?(cache_key(id))
|
101
104
|
end
|
102
|
-
|
103
105
|
end
|
104
106
|
end
|
data/lib/hold/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Willson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -140,20 +140,6 @@ dependencies:
|
|
140
140
|
description: |2
|
141
141
|
A persistence library based more closely on the repository model.
|
142
142
|
Used in production for several years.
|
143
|
-
|
144
|
-
To summarize, the idea is that
|
145
|
-
|
146
|
-
* You have Repositories which are responsible for persisting objects in a data store
|
147
|
-
* Your data objects know nothing about persistence. They are just 'plain old' in-memory ruby objects can be created and manipulated independently of any particular repository.
|
148
|
-
|
149
|
-
This is a substantially different approach to the widely used ActiveRecord pattern.
|
150
|
-
|
151
|
-
Of course there are various trade-offs involved when choosing between these two approaches. ActiveRecord is a more lightweight approach which is often preferred for small-to-mid-sized database-backed web applications where the data model is tightly coupled to a database schema; whereas Repositories start to show benefits when it comes to, e.g.:
|
152
|
-
|
153
|
-
* Separation of concerns in a larger system; avoiding bloated model classes with too many responsibilities
|
154
|
-
* Ease of switching between alternative back-end data stores, e.g. database-backed vs persisted-in-a-config-file vs persisted in-memory. In particular, this can help avoid database dependencies when testing
|
155
|
-
* Systems which persist objects in multiple data stores -- e.g. in a relational database, serialized in a key-value cache, serialized in config files, ...
|
156
|
-
* Decoupling the structure of your data model from the schema of the data store used to persist it
|
157
143
|
email:
|
158
144
|
- mark@mediasp.com
|
159
145
|
- tom@mediasp.com
|