commutator 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Changelog.md +13 -2
- data/README.md +6 -1
- data/commutator.gemspec +1 -0
- data/lib/commutator.rb +2 -1
- data/lib/commutator/model.rb +20 -7
- data/lib/commutator/model/table_configuration.rb +11 -2
- data/lib/commutator/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dffefbc083f0f661a472dc48a7f9eb973e0cf42c
|
4
|
+
data.tar.gz: b8f9ef383327ba1f1c8fcd106b6708bfa2e1011b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e08de421af87b4f1e44b015d4fba944842103d604104cad7920317c80aef3a493e3651738819954bebc82aef73d80ad39888b4604b9c887a63ebc948129fbdb1
|
7
|
+
data.tar.gz: 1b3fa727463ae2bcf2962447cb49944cb782c1c985716b6ccf3afda4cf72fd879028b7efaca89bf7384c80d3b23a405b50fa5820a3e7b059c2cddb37df18b481
|
data/.gitignore
CHANGED
data/Changelog.md
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
### Development
|
2
|
-
[Full Changelog](http://github.com/tablexi/commutator/compare/v0.
|
2
|
+
[Full Changelog](http://github.com/tablexi/commutator/compare/v0.2.0...master)
|
3
3
|
|
4
|
-
###
|
4
|
+
### 0.2.0 / 2016-03-07
|
5
|
+
|
6
|
+
Features:
|
7
|
+
|
8
|
+
* Can configure table name at the instance level. (Bradley Schaefer)
|
9
|
+
* Port over a ton of Ben Kimpel's tests (Bradley Schaefer)
|
10
|
+
|
11
|
+
Bug fixes:
|
12
|
+
|
13
|
+
* Resolve a concurrency bug involving lazy instantiation (Bradley Schaefer)
|
14
|
+
|
15
|
+
### 0.1.1 / 2016-01-15
|
5
16
|
[Full Changelog](http://github.com/tablexi/commutator/compare/v0.1.0...v0.1.1)
|
6
17
|
|
7
18
|
Features:
|
data/README.md
CHANGED
@@ -71,7 +71,12 @@ Color.create(name: "Black", hex_color: "#000000")
|
|
71
71
|
|
72
72
|
## Development
|
73
73
|
|
74
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
74
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
75
|
+
|
76
|
+
DynamoDB Local is also required for running tests [tagged with :dynamo => true](/spec/spec_helper#L6). Check the
|
77
|
+
[Amazon Documentation for Downloading and Running DynamoDB Local](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html#Tools.DynamoDBLocal.DownloadingAndRunning).
|
78
|
+
|
79
|
+
Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
75
80
|
|
76
81
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
77
82
|
|
data/commutator.gemspec
CHANGED
data/lib/commutator.rb
CHANGED
data/lib/commutator/model.rb
CHANGED
@@ -50,6 +50,9 @@ module Commutator
|
|
50
50
|
class_attribute :collection_item_modifiers, instance_accessor: false
|
51
51
|
class_attribute :client
|
52
52
|
self.client = ::Commutator::SimpleClient.new
|
53
|
+
|
54
|
+
class_attribute :scoped_options, instance_accessor: false
|
55
|
+
self.scoped_options = options_cache_class
|
53
56
|
end
|
54
57
|
|
55
58
|
delegate :options_class, to: 'self.class'
|
@@ -139,6 +142,7 @@ module Commutator
|
|
139
142
|
subclass.table_name(table_name)
|
140
143
|
subclass.primary_key(hash: primary_key_hash_name,
|
141
144
|
range: primary_key_range_name)
|
145
|
+
subclass.scoped_options = option_class_cache
|
142
146
|
|
143
147
|
scopes = const_defined?("Scopes", false) ? const_get("Scopes") : nil
|
144
148
|
subclass.const_set("Scopes", Module.new { include scopes }) if scopes
|
@@ -184,12 +188,7 @@ module Commutator
|
|
184
188
|
end
|
185
189
|
|
186
190
|
def options_class(operation)
|
187
|
-
|
188
|
-
scopes = self.const_defined?("Scopes", false) ? self.const_get("Scopes") : nil
|
189
|
-
const_name = k.to_s.camelize
|
190
|
-
h[k] = enhance_options(const_name, scopes)
|
191
|
-
end
|
192
|
-
@scoped_options[operation]
|
191
|
+
scoped_options[operation]
|
193
192
|
end
|
194
193
|
|
195
194
|
def method_missing(method, *args)
|
@@ -203,13 +202,27 @@ module Commutator
|
|
203
202
|
|
204
203
|
private
|
205
204
|
|
205
|
+
def options_cache_class
|
206
|
+
Concurrent::Map.new do |h, k|
|
207
|
+
scopes = self.const_defined?("Scopes", false) ? self.const_get("Scopes") : nil
|
208
|
+
h.compute_if_absent(k) do
|
209
|
+
const_name = k.to_s.camelize
|
210
|
+
enhance_options(const_name, scopes)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
206
215
|
def enhance_options(const_name, scopes = nil)
|
207
|
-
Class.new(Options.const_get(const_name)) do
|
216
|
+
Class.new(Options.const_get(const_name, false)) do
|
208
217
|
include ::Commutator::Util::Fluent
|
209
218
|
include scopes if scopes && %w[Query Scan].include?(const_name)
|
210
219
|
|
211
220
|
fluent_accessor :_proxy
|
212
221
|
delegate :context, to: :_proxy
|
222
|
+
|
223
|
+
def inspect
|
224
|
+
"#{const_name}Proxy (#{(public_methods.sort - Object.methods).join(", ")})"
|
225
|
+
end
|
213
226
|
end
|
214
227
|
end
|
215
228
|
|
@@ -16,8 +16,17 @@ module Commutator
|
|
16
16
|
send(primary_key_range_name) if primary_key_range_name.present?
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
included do
|
20
|
+
class_attribute :table_name
|
21
|
+
|
22
|
+
class << self
|
23
|
+
prepend(Module.new do
|
24
|
+
def table_name(*args)
|
25
|
+
return super if args.size == 0
|
26
|
+
send("table_name=", *args)
|
27
|
+
end
|
28
|
+
end)
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
32
|
# :nodoc:
|
data/lib/commutator/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commutator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bradley Schaefer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -109,6 +109,20 @@ dependencies:
|
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: concurrent-ruby
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '1.0'
|
119
|
+
type: :runtime
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '1.0'
|
112
126
|
description: Model object interface for Amazon DynamoDB.
|
113
127
|
email:
|
114
128
|
- bradley.schaefer@gmail.com
|