dynamoid-moda 0.7.1
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 +15 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +118 -0
- data/Gemfile_activemodel4 +24 -0
- data/Gemfile_activemodel4.lock +88 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +360 -0
- data/Rakefile +93 -0
- data/VERSION +1 -0
- data/doc/.nojekyll +0 -0
- data/doc/Dynamoid.html +328 -0
- data/doc/Dynamoid/Adapter.html +1872 -0
- data/doc/Dynamoid/Adapter/AwsSdk.html +2101 -0
- data/doc/Dynamoid/Adapter/Local.html +1574 -0
- data/doc/Dynamoid/Associations.html +138 -0
- data/doc/Dynamoid/Associations/Association.html +847 -0
- data/doc/Dynamoid/Associations/BelongsTo.html +161 -0
- data/doc/Dynamoid/Associations/ClassMethods.html +766 -0
- data/doc/Dynamoid/Associations/HasAndBelongsToMany.html +167 -0
- data/doc/Dynamoid/Associations/HasMany.html +167 -0
- data/doc/Dynamoid/Associations/HasOne.html +161 -0
- data/doc/Dynamoid/Associations/ManyAssociation.html +1684 -0
- data/doc/Dynamoid/Associations/SingleAssociation.html +627 -0
- data/doc/Dynamoid/Components.html +242 -0
- data/doc/Dynamoid/Config.html +412 -0
- data/doc/Dynamoid/Config/Options.html +638 -0
- data/doc/Dynamoid/Criteria.html +138 -0
- data/doc/Dynamoid/Criteria/Chain.html +1471 -0
- data/doc/Dynamoid/Criteria/ClassMethods.html +105 -0
- data/doc/Dynamoid/Dirty.html +424 -0
- data/doc/Dynamoid/Dirty/ClassMethods.html +174 -0
- data/doc/Dynamoid/Document.html +1033 -0
- data/doc/Dynamoid/Document/ClassMethods.html +1116 -0
- data/doc/Dynamoid/Errors.html +125 -0
- data/doc/Dynamoid/Errors/ConditionalCheckFailedException.html +141 -0
- data/doc/Dynamoid/Errors/DocumentNotValid.html +221 -0
- data/doc/Dynamoid/Errors/Error.html +137 -0
- data/doc/Dynamoid/Errors/InvalidField.html +141 -0
- data/doc/Dynamoid/Errors/InvalidQuery.html +131 -0
- data/doc/Dynamoid/Errors/MissingRangeKey.html +141 -0
- data/doc/Dynamoid/Fields.html +686 -0
- data/doc/Dynamoid/Fields/ClassMethods.html +438 -0
- data/doc/Dynamoid/Finders.html +135 -0
- data/doc/Dynamoid/Finders/ClassMethods.html +943 -0
- data/doc/Dynamoid/IdentityMap.html +492 -0
- data/doc/Dynamoid/IdentityMap/ClassMethods.html +534 -0
- data/doc/Dynamoid/Indexes.html +321 -0
- data/doc/Dynamoid/Indexes/ClassMethods.html +369 -0
- data/doc/Dynamoid/Indexes/Index.html +1142 -0
- data/doc/Dynamoid/Middleware.html +115 -0
- data/doc/Dynamoid/Middleware/IdentityMap.html +264 -0
- data/doc/Dynamoid/Persistence.html +892 -0
- data/doc/Dynamoid/Persistence/ClassMethods.html +836 -0
- data/doc/Dynamoid/Validations.html +415 -0
- data/doc/_index.html +506 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +338 -0
- data/doc/file.LICENSE.html +73 -0
- data/doc/file.README.html +416 -0
- data/doc/file_list.html +58 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +416 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +1144 -0
- data/doc/top-level-namespace.html +112 -0
- data/dynamoid-moda.gemspec +210 -0
- data/dynamoid.gemspec +208 -0
- data/lib/dynamoid.rb +46 -0
- data/lib/dynamoid/adapter.rb +267 -0
- data/lib/dynamoid/adapter/aws_sdk.rb +309 -0
- data/lib/dynamoid/associations.rb +106 -0
- data/lib/dynamoid/associations/association.rb +105 -0
- data/lib/dynamoid/associations/belongs_to.rb +44 -0
- data/lib/dynamoid/associations/has_and_belongs_to_many.rb +40 -0
- data/lib/dynamoid/associations/has_many.rb +39 -0
- data/lib/dynamoid/associations/has_one.rb +39 -0
- data/lib/dynamoid/associations/many_association.rb +191 -0
- data/lib/dynamoid/associations/single_association.rb +69 -0
- data/lib/dynamoid/components.rb +37 -0
- data/lib/dynamoid/config.rb +57 -0
- data/lib/dynamoid/config/options.rb +78 -0
- data/lib/dynamoid/criteria.rb +29 -0
- data/lib/dynamoid/criteria/chain.rb +326 -0
- data/lib/dynamoid/dirty.rb +47 -0
- data/lib/dynamoid/document.rb +199 -0
- data/lib/dynamoid/errors.rb +28 -0
- data/lib/dynamoid/fields.rb +138 -0
- data/lib/dynamoid/finders.rb +133 -0
- data/lib/dynamoid/identity_map.rb +96 -0
- data/lib/dynamoid/indexes.rb +69 -0
- data/lib/dynamoid/indexes/index.rb +103 -0
- data/lib/dynamoid/middleware/identity_map.rb +16 -0
- data/lib/dynamoid/persistence.rb +292 -0
- data/lib/dynamoid/validations.rb +36 -0
- data/spec/app/models/address.rb +13 -0
- data/spec/app/models/camel_case.rb +34 -0
- data/spec/app/models/car.rb +6 -0
- data/spec/app/models/magazine.rb +11 -0
- data/spec/app/models/message.rb +9 -0
- data/spec/app/models/nuclear_submarine.rb +5 -0
- data/spec/app/models/sponsor.rb +8 -0
- data/spec/app/models/subscription.rb +12 -0
- data/spec/app/models/tweet.rb +12 -0
- data/spec/app/models/user.rb +26 -0
- data/spec/app/models/vehicle.rb +7 -0
- data/spec/dynamoid/adapter/aws_sdk_spec.rb +376 -0
- data/spec/dynamoid/adapter_spec.rb +155 -0
- data/spec/dynamoid/associations/association_spec.rb +194 -0
- data/spec/dynamoid/associations/belongs_to_spec.rb +71 -0
- data/spec/dynamoid/associations/has_and_belongs_to_many_spec.rb +47 -0
- data/spec/dynamoid/associations/has_many_spec.rb +42 -0
- data/spec/dynamoid/associations/has_one_spec.rb +45 -0
- data/spec/dynamoid/associations_spec.rb +16 -0
- data/spec/dynamoid/config_spec.rb +27 -0
- data/spec/dynamoid/criteria/chain_spec.rb +210 -0
- data/spec/dynamoid/criteria_spec.rb +75 -0
- data/spec/dynamoid/dirty_spec.rb +57 -0
- data/spec/dynamoid/document_spec.rb +180 -0
- data/spec/dynamoid/fields_spec.rb +156 -0
- data/spec/dynamoid/finders_spec.rb +147 -0
- data/spec/dynamoid/identity_map_spec.rb +45 -0
- data/spec/dynamoid/indexes/index_spec.rb +104 -0
- data/spec/dynamoid/indexes_spec.rb +25 -0
- data/spec/dynamoid/persistence_spec.rb +301 -0
- data/spec/dynamoid/validations_spec.rb +36 -0
- data/spec/dynamoid_spec.rb +14 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/support/with_partitioning.rb +15 -0
- metadata +363 -0
data/Rakefile
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'bundler'
|
|
5
|
+
begin
|
|
6
|
+
Bundler.setup(:default, :development)
|
|
7
|
+
rescue Bundler::BundlerError => e
|
|
8
|
+
$stderr.puts e.message
|
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
+
exit e.status_code
|
|
11
|
+
end
|
|
12
|
+
require 'rake'
|
|
13
|
+
|
|
14
|
+
require 'jeweler'
|
|
15
|
+
Jeweler::Tasks.new do |gem|
|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
17
|
+
gem.name = "dynamoid-moda"
|
|
18
|
+
gem.homepage = "http://github.com/Veraticus/Dynamoid"
|
|
19
|
+
gem.license = "MIT"
|
|
20
|
+
gem.summary = "Dynamoid is an ORM for Amazon's DynamoDB"
|
|
21
|
+
gem.description = "Dynamoid is an ORM for Amazon's DynamoDB that supports offline development, associations, querying, and everything else you'd expect from an ActiveRecord-style replacement."
|
|
22
|
+
gem.email = "josh@joshsymonds.com"
|
|
23
|
+
gem.authors = ["Josh Symonds"]
|
|
24
|
+
# dependencies defined in Gemfile
|
|
25
|
+
end
|
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
27
|
+
|
|
28
|
+
require 'rspec/core'
|
|
29
|
+
require 'rspec/core/rake_task'
|
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
36
|
+
spec.rcov = true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
desc "Start fake_dynamo, run tests, cleanup"
|
|
40
|
+
task :unattended_spec do |t|
|
|
41
|
+
require 'tmpdir'
|
|
42
|
+
require 'socket'
|
|
43
|
+
|
|
44
|
+
dir = Dir.mktmpdir
|
|
45
|
+
data_file = File.join(dir, "data.fdb")
|
|
46
|
+
|
|
47
|
+
#Launch fake_dynamo
|
|
48
|
+
pid = Process.spawn'fake_dynamo', '-d', data_file, err: '/dev/null', out: '/dev/null'
|
|
49
|
+
#Cleanup
|
|
50
|
+
at_exit {
|
|
51
|
+
Process.kill('TERM', pid)
|
|
52
|
+
FileUtils.rmtree(dir)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#Wait for fake_dynamo to start taking requests
|
|
56
|
+
40.downto(0) do |count| #Wait up to 2 seconds
|
|
57
|
+
begin
|
|
58
|
+
s = TCPSocket.new 'localhost', 4567
|
|
59
|
+
s.close
|
|
60
|
+
break
|
|
61
|
+
rescue Errno::ECONNREFUSED
|
|
62
|
+
raise if(count == 0)
|
|
63
|
+
sleep 0.1
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
Rake::Task["spec"].invoke
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
require 'yard'
|
|
71
|
+
YARD::Rake::YardocTask.new do |t|
|
|
72
|
+
t.files = ['lib/**/*.rb', "README", "LICENSE"] # optional
|
|
73
|
+
t.options = ['-m', 'markdown'] # optional
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
desc 'Publish documentation to gh-pages'
|
|
77
|
+
task :publish do
|
|
78
|
+
Rake::Task['yard'].invoke
|
|
79
|
+
`git add .`
|
|
80
|
+
`git commit -m 'Regenerated documentation'`
|
|
81
|
+
`git checkout gh-pages`
|
|
82
|
+
`git clean -fdx`
|
|
83
|
+
`git checkout master -- doc`
|
|
84
|
+
`cp -R doc/* .`
|
|
85
|
+
`git rm -rf doc/`
|
|
86
|
+
`git add .`
|
|
87
|
+
`git commit -m 'Regenerated documentation'`
|
|
88
|
+
`git pull`
|
|
89
|
+
`git push`
|
|
90
|
+
`git checkout master`
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
task :default => :spec
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.7.1
|
data/doc/.nojekyll
ADDED
|
File without changes
|
data/doc/Dynamoid.html
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
6
|
+
<title>
|
|
7
|
+
Module: Dynamoid
|
|
8
|
+
|
|
9
|
+
— Documentation by YARD 0.8.6.1
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
|
19
|
+
relpath = '';
|
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
|
25
|
+
|
|
26
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<div id="header">
|
|
32
|
+
<div id="menu">
|
|
33
|
+
|
|
34
|
+
<a href="_index.html">Index (D)</a> »
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
<span class="title">Dynamoid</span>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div id="search">
|
|
44
|
+
|
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
|
46
|
+
href="class_list.html">
|
|
47
|
+
Class List
|
|
48
|
+
</a>
|
|
49
|
+
|
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
|
51
|
+
href="method_list.html">
|
|
52
|
+
Method List
|
|
53
|
+
</a>
|
|
54
|
+
|
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
|
56
|
+
href="file_list.html">
|
|
57
|
+
File List
|
|
58
|
+
</a>
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
<div class="clear"></div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<iframe id="search_frame"></iframe>
|
|
65
|
+
|
|
66
|
+
<div id="content"><h1>Module: Dynamoid
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
</h1>
|
|
71
|
+
|
|
72
|
+
<dl class="box">
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
<dt class="r1">Extended by:</dt>
|
|
77
|
+
<dd class="r1"><span class='object_link'><a href="" title="Dynamoid (module)">Dynamoid</a></span></dd>
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
<dt class="r2">Included in:</dt>
|
|
85
|
+
<dd class="r2"><span class='object_link'><a href="" title="Dynamoid (module)">Dynamoid</a></span></dd>
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
<dt class="r1 last">Defined in:</dt>
|
|
90
|
+
<dd class="r1 last">lib/dynamoid/fields.rb<span class="defines">,<br />
|
|
91
|
+
lib/dynamoid.rb,<br /> lib/dynamoid/dirty.rb,<br /> lib/dynamoid/errors.rb,<br /> lib/dynamoid/config.rb,<br /> lib/dynamoid/indexes.rb,<br /> lib/dynamoid/adapter.rb,<br /> lib/dynamoid/finders.rb,<br /> lib/dynamoid/document.rb,<br /> lib/dynamoid/criteria.rb,<br /> lib/dynamoid/components.rb,<br /> lib/dynamoid/validations.rb,<br /> lib/dynamoid/persistence.rb,<br /> lib/dynamoid/identity_map.rb,<br /> lib/dynamoid/associations.rb,<br /> lib/dynamoid/indexes/index.rb,<br /> lib/dynamoid/config/options.rb,<br /> lib/dynamoid/criteria/chain.rb,<br /> lib/dynamoid/adapter/aws_sdk.rb,<br /> lib/dynamoid/associations/has_one.rb,<br /> lib/dynamoid/associations/has_many.rb,<br /> lib/dynamoid/associations/belongs_to.rb,<br /> lib/dynamoid/middleware/identity_map.rb,<br /> lib/dynamoid/associations/association.rb,<br /> lib/dynamoid/associations/many_association.rb,<br /> lib/dynamoid/associations/single_association.rb,<br /> lib/dynamoid/associations/has_and_belongs_to_many.rb</span>
|
|
92
|
+
</dd>
|
|
93
|
+
|
|
94
|
+
</dl>
|
|
95
|
+
<div class="clear"></div>
|
|
96
|
+
|
|
97
|
+
<h2>Overview</h2><div class="docstring">
|
|
98
|
+
<div class="discussion">
|
|
99
|
+
<p>:nodoc:</p>
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
<div class="tags">
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
</div><h2>Defined Under Namespace</h2>
|
|
108
|
+
<p class="children">
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Dynamoid/Adapter.html" title="Dynamoid::Adapter (module)">Adapter</a></span>, <span class='object_link'><a href="Dynamoid/Associations.html" title="Dynamoid::Associations (module)">Associations</a></span>, <span class='object_link'><a href="Dynamoid/Components.html" title="Dynamoid::Components (module)">Components</a></span>, <span class='object_link'><a href="Dynamoid/Config.html" title="Dynamoid::Config (module)">Config</a></span>, <span class='object_link'><a href="Dynamoid/Criteria.html" title="Dynamoid::Criteria (module)">Criteria</a></span>, <span class='object_link'><a href="Dynamoid/Dirty.html" title="Dynamoid::Dirty (module)">Dirty</a></span>, <span class='object_link'><a href="Dynamoid/Document.html" title="Dynamoid::Document (module)">Document</a></span>, <span class='object_link'><a href="Dynamoid/Errors.html" title="Dynamoid::Errors (module)">Errors</a></span>, <span class='object_link'><a href="Dynamoid/Fields.html" title="Dynamoid::Fields (module)">Fields</a></span>, <span class='object_link'><a href="Dynamoid/Finders.html" title="Dynamoid::Finders (module)">Finders</a></span>, <span class='object_link'><a href="Dynamoid/IdentityMap.html" title="Dynamoid::IdentityMap (module)">IdentityMap</a></span>, <span class='object_link'><a href="Dynamoid/Indexes.html" title="Dynamoid::Indexes (module)">Indexes</a></span>, <span class='object_link'><a href="Dynamoid/Middleware.html" title="Dynamoid::Middleware (module)">Middleware</a></span>, <span class='object_link'><a href="Dynamoid/Persistence.html" title="Dynamoid::Persistence (module)">Persistence</a></span>, <span class='object_link'><a href="Dynamoid/Validations.html" title="Dynamoid::Validations (module)">Validations</a></span>
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
</p>
|
|
117
|
+
|
|
118
|
+
<h2>Constant Summary</h2>
|
|
119
|
+
|
|
120
|
+
<dl class="constants">
|
|
121
|
+
|
|
122
|
+
<dt id="MAX_ITEM_SIZE-constant" class="">MAX_ITEM_SIZE =
|
|
123
|
+
|
|
124
|
+
</dt>
|
|
125
|
+
<dd><pre class="code"><span class='int'>65_536</span></pre></dd>
|
|
126
|
+
|
|
127
|
+
</dl>
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
<h2>
|
|
138
|
+
Instance Method Summary
|
|
139
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
|
140
|
+
</h2>
|
|
141
|
+
|
|
142
|
+
<ul class="summary">
|
|
143
|
+
|
|
144
|
+
<li class="public ">
|
|
145
|
+
<span class="summary_signature">
|
|
146
|
+
|
|
147
|
+
<a href="#configure-instance_method" title="#configure (instance method)">- (Object) <strong>configure</strong> </a>
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
(also: #config)
|
|
152
|
+
|
|
153
|
+
</span>
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
164
|
+
|
|
165
|
+
</li>
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
<li class="public ">
|
|
169
|
+
<span class="summary_signature">
|
|
170
|
+
|
|
171
|
+
<a href="#included_models-instance_method" title="#included_models (instance method)">- (Object) <strong>included_models</strong> </a>
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
</span>
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
186
|
+
|
|
187
|
+
</li>
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
<li class="public ">
|
|
191
|
+
<span class="summary_signature">
|
|
192
|
+
|
|
193
|
+
<a href="#logger-instance_method" title="#logger (instance method)">- (Object) <strong>logger</strong> </a>
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
</span>
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
208
|
+
|
|
209
|
+
</li>
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
</ul>
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
<div id="instance_method_details" class="method_details_list">
|
|
218
|
+
<h2>Instance Method Details</h2>
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
<div class="method_details first">
|
|
222
|
+
<h3 class="signature first" id="configure-instance_method">
|
|
223
|
+
|
|
224
|
+
- (<tt>Object</tt>) <strong>configure</strong>
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
<span class="aliases">Also known as:
|
|
229
|
+
<span class="names"><span id='config-instance_method'>config</span></span>
|
|
230
|
+
</span>
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
</h3><table class="source_code">
|
|
235
|
+
<tr>
|
|
236
|
+
<td>
|
|
237
|
+
<pre class="lines">
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
33
|
|
241
|
+
34
|
|
242
|
+
35
|
|
243
|
+
36</pre>
|
|
244
|
+
</td>
|
|
245
|
+
<td>
|
|
246
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid.rb', line 33</span>
|
|
247
|
+
|
|
248
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_configure'>configure</span>
|
|
249
|
+
<span class='id identifier rubyid_block_given?'>block_given?</span> <span class='op'>?</span> <span class='kw'>yield</span><span class='lparen'>(</span><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span>
|
|
250
|
+
<span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_reconnect!'>reconnect!</span>
|
|
251
|
+
<span class='kw'>end</span></pre>
|
|
252
|
+
</td>
|
|
253
|
+
</tr>
|
|
254
|
+
</table>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
<div class="method_details ">
|
|
258
|
+
<h3 class="signature " id="included_models-instance_method">
|
|
259
|
+
|
|
260
|
+
- (<tt>Object</tt>) <strong>included_models</strong>
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
</h3><table class="source_code">
|
|
267
|
+
<tr>
|
|
268
|
+
<td>
|
|
269
|
+
<pre class="lines">
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
43
|
|
273
|
+
44
|
|
274
|
+
45</pre>
|
|
275
|
+
</td>
|
|
276
|
+
<td>
|
|
277
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid.rb', line 43</span>
|
|
278
|
+
|
|
279
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_included_models'>included_models</span>
|
|
280
|
+
<span class='ivar'>@included_models</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
|
281
|
+
<span class='kw'>end</span></pre>
|
|
282
|
+
</td>
|
|
283
|
+
</tr>
|
|
284
|
+
</table>
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<div class="method_details ">
|
|
288
|
+
<h3 class="signature " id="logger-instance_method">
|
|
289
|
+
|
|
290
|
+
- (<tt>Object</tt>) <strong>logger</strong>
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
</h3><table class="source_code">
|
|
297
|
+
<tr>
|
|
298
|
+
<td>
|
|
299
|
+
<pre class="lines">
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
39
|
|
303
|
+
40
|
|
304
|
+
41</pre>
|
|
305
|
+
</td>
|
|
306
|
+
<td>
|
|
307
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid.rb', line 39</span>
|
|
308
|
+
|
|
309
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_logger'>logger</span>
|
|
310
|
+
<span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span>
|
|
311
|
+
<span class='kw'>end</span></pre>
|
|
312
|
+
</td>
|
|
313
|
+
</tr>
|
|
314
|
+
</table>
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
</div>
|
|
318
|
+
|
|
319
|
+
</div>
|
|
320
|
+
|
|
321
|
+
<div id="footer">
|
|
322
|
+
Generated on Thu Jun 27 21:59:09 2013 by
|
|
323
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
324
|
+
0.8.6.1 (ruby-1.9.3).
|
|
325
|
+
</div>
|
|
326
|
+
|
|
327
|
+
</body>
|
|
328
|
+
</html>
|
|
@@ -0,0 +1,1872 @@
|
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
6
|
+
<title>
|
|
7
|
+
Module: Dynamoid::Adapter
|
|
8
|
+
|
|
9
|
+
— Documentation by YARD 0.8.6.1
|
|
10
|
+
|
|
11
|
+
</title>
|
|
12
|
+
|
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
|
14
|
+
|
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
|
19
|
+
relpath = '../';
|
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
|
25
|
+
|
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<div id="header">
|
|
32
|
+
<div id="menu">
|
|
33
|
+
|
|
34
|
+
<a href="../_index.html">Index (A)</a> »
|
|
35
|
+
<span class='title'><span class='object_link'><a href="../Dynamoid.html" title="Dynamoid (module)">Dynamoid</a></span></span>
|
|
36
|
+
»
|
|
37
|
+
<span class="title">Adapter</span>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div id="search">
|
|
44
|
+
|
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
|
46
|
+
href="../class_list.html">
|
|
47
|
+
Class List
|
|
48
|
+
</a>
|
|
49
|
+
|
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
|
51
|
+
href="../method_list.html">
|
|
52
|
+
Method List
|
|
53
|
+
</a>
|
|
54
|
+
|
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
|
56
|
+
href="../file_list.html">
|
|
57
|
+
File List
|
|
58
|
+
</a>
|
|
59
|
+
|
|
60
|
+
</div>
|
|
61
|
+
<div class="clear"></div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<iframe id="search_frame"></iframe>
|
|
65
|
+
|
|
66
|
+
<div id="content"><h1>Module: Dynamoid::Adapter
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
</h1>
|
|
71
|
+
|
|
72
|
+
<dl class="box">
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
<dt class="r1">Extended by:</dt>
|
|
77
|
+
<dd class="r1"><span class='object_link'><a href="" title="Dynamoid::Adapter (module)">Adapter</a></span></dd>
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
<dt class="r2">Included in:</dt>
|
|
85
|
+
<dd class="r2"><span class='object_link'><a href="" title="Dynamoid::Adapter (module)">Adapter</a></span></dd>
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
<dt class="r1 last">Defined in:</dt>
|
|
90
|
+
<dd class="r1 last">lib/dynamoid/adapter.rb<span class="defines">,<br />
|
|
91
|
+
lib/dynamoid/adapter/aws_sdk.rb</span>
|
|
92
|
+
</dd>
|
|
93
|
+
|
|
94
|
+
</dl>
|
|
95
|
+
<div class="clear"></div>
|
|
96
|
+
|
|
97
|
+
<h2>Overview</h2><div class="docstring">
|
|
98
|
+
<div class="discussion">
|
|
99
|
+
<p>Adapter provides a generic, write-through class that abstracts variations in the underlying connections to provide a uniform response
|
|
100
|
+
to Dynamoid.</p>
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
<div class="tags">
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
</div><h2>Defined Under Namespace</h2>
|
|
109
|
+
<p class="children">
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Adapter/AwsSdk.html" title="Dynamoid::Adapter::AwsSdk (module)">AwsSdk</a></span>
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
</p>
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
|
123
|
+
<ul class="summary">
|
|
124
|
+
|
|
125
|
+
<li class="public ">
|
|
126
|
+
<span class="summary_signature">
|
|
127
|
+
|
|
128
|
+
<a href="#tables-instance_method" title="#tables (instance method)">- (Object) <strong>tables</strong> </a>
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
</span>
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
<span class="summary_desc"><div class='inline'><p>Returns the value of attribute tables.</p>
|
|
146
|
+
</div></span>
|
|
147
|
+
|
|
148
|
+
</li>
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
</ul>
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
<h2>
|
|
158
|
+
Instance Method Summary
|
|
159
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
|
160
|
+
</h2>
|
|
161
|
+
|
|
162
|
+
<ul class="summary">
|
|
163
|
+
|
|
164
|
+
<li class="public ">
|
|
165
|
+
<span class="summary_signature">
|
|
166
|
+
|
|
167
|
+
<a href="#adapter-instance_method" title="#adapter (instance method)">- (Object) <strong>adapter</strong> </a>
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
</span>
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
<span class="summary_desc"><div class='inline'><p>The actual adapter currently in use: presently AwsSdk.</p>
|
|
182
|
+
</div></span>
|
|
183
|
+
|
|
184
|
+
</li>
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
<li class="public ">
|
|
188
|
+
<span class="summary_signature">
|
|
189
|
+
|
|
190
|
+
<a href="#benchmark-instance_method" title="#benchmark (instance method)">- (Object) <strong>benchmark</strong>(method, *args) { ... }</a>
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
</span>
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
<span class="summary_desc"><div class='inline'><p>Shows how long it takes a method to run on the adapter.</p>
|
|
205
|
+
</div></span>
|
|
206
|
+
|
|
207
|
+
</li>
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
<li class="public ">
|
|
211
|
+
<span class="summary_signature">
|
|
212
|
+
|
|
213
|
+
<a href="#delete-instance_method" title="#delete (instance method)">- (Object) <strong>delete</strong>(table, ids, options = {}) </a>
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
</span>
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
<span class="summary_desc"><div class='inline'><p>Delete an item from a table.</p>
|
|
228
|
+
</div></span>
|
|
229
|
+
|
|
230
|
+
</li>
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
<li class="public ">
|
|
234
|
+
<span class="summary_signature">
|
|
235
|
+
|
|
236
|
+
<a href="#get_original_id_and_partition-instance_method" title="#get_original_id_and_partition (instance method)">- (String) <strong>get_original_id_and_partition</strong>(id) </a>
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
</span>
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
<span class="summary_desc"><div class='inline'><p>Get original id (hash_key) and partiton number from a hash_key.</p>
|
|
251
|
+
</div></span>
|
|
252
|
+
|
|
253
|
+
</li>
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
<li class="public ">
|
|
257
|
+
<span class="summary_signature">
|
|
258
|
+
|
|
259
|
+
<a href="#id_with_partitions-instance_method" title="#id_with_partitions (instance method)">- (Object) <strong>id_with_partitions</strong>(ids) </a>
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
</span>
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
<span class="summary_desc"><div class='inline'><p>Takes a list of ids and returns them with partitioning added.</p>
|
|
274
|
+
</div></span>
|
|
275
|
+
|
|
276
|
+
</li>
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
<li class="public ">
|
|
280
|
+
<span class="summary_signature">
|
|
281
|
+
|
|
282
|
+
<a href="#method_missing-instance_method" title="#method_missing (instance method)">- (Object) <strong>method_missing</strong>(method, *args, &block) </a>
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
</span>
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
<span class="summary_desc"><div class='inline'><p>Delegate all methods that aren't defind here to the underlying adapter.</p>
|
|
297
|
+
</div></span>
|
|
298
|
+
|
|
299
|
+
</li>
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
<li class="public ">
|
|
303
|
+
<span class="summary_signature">
|
|
304
|
+
|
|
305
|
+
<a href="#query-instance_method" title="#query (instance method)">- (Array) <strong>query</strong>(table_name, opts = {}) </a>
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
</span>
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
<span class="summary_desc"><div class='inline'><p>Query the DynamoDB table.</p>
|
|
320
|
+
</div></span>
|
|
321
|
+
|
|
322
|
+
</li>
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
<li class="public ">
|
|
326
|
+
<span class="summary_signature">
|
|
327
|
+
|
|
328
|
+
<a href="#read-instance_method" title="#read (instance method)">- (Object) <strong>read</strong>(table, ids, options = {}) </a>
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
</span>
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
<span class="summary_desc"><div class='inline'><p>Read one or many keys from the selected table.</p>
|
|
343
|
+
</div></span>
|
|
344
|
+
|
|
345
|
+
</li>
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
<li class="public ">
|
|
349
|
+
<span class="summary_signature">
|
|
350
|
+
|
|
351
|
+
<a href="#reconnect%21-instance_method" title="#reconnect! (instance method)">- (Object) <strong>reconnect!</strong> </a>
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
</span>
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
<span class="summary_desc"><div class='inline'><p>Establishes a connection to the underyling adapter and caches all its tables for speedier future lookups.</p>
|
|
366
|
+
</div></span>
|
|
367
|
+
|
|
368
|
+
</li>
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
<li class="public ">
|
|
372
|
+
<span class="summary_signature">
|
|
373
|
+
|
|
374
|
+
<a href="#result_for_partition-instance_method" title="#result_for_partition (instance method)">- (Object) <strong>result_for_partition</strong>(results, table_name) </a>
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
</span>
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
<span class="summary_desc"><div class='inline'><p>Takes an array of query results that are partitioned, find the most recently updated ones that share an id and range_key, and return only the most recently updated.</p>
|
|
389
|
+
</div></span>
|
|
390
|
+
|
|
391
|
+
</li>
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
<li class="public ">
|
|
395
|
+
<span class="summary_signature">
|
|
396
|
+
|
|
397
|
+
<a href="#scan-instance_method" title="#scan (instance method)">- (Object) <strong>scan</strong>(table, query, opts = {}) </a>
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
</span>
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
<span class="summary_desc"><div class='inline'><p>Scans a table.</p>
|
|
412
|
+
</div></span>
|
|
413
|
+
|
|
414
|
+
</li>
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
<li class="public ">
|
|
418
|
+
<span class="summary_signature">
|
|
419
|
+
|
|
420
|
+
<a href="#write-instance_method" title="#write (instance method)">- (Object) <strong>write</strong>(table, object, options = nil) </a>
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
</span>
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
<span class="summary_desc"><div class='inline'><p>Write an object to the adapter.</p>
|
|
435
|
+
</div></span>
|
|
436
|
+
|
|
437
|
+
</li>
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
</ul>
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
<div id="method_missing_details" class="method_details_list">
|
|
444
|
+
<h2>Dynamic Method Handling</h2>
|
|
445
|
+
<p class="notice this">
|
|
446
|
+
This class handles dynamic methods through the <tt>method_missing</tt> method
|
|
447
|
+
|
|
448
|
+
</p>
|
|
449
|
+
|
|
450
|
+
<div class="method_details first">
|
|
451
|
+
<h3 class="signature first" id="method_missing-instance_method">
|
|
452
|
+
|
|
453
|
+
- (<tt>Object</tt>) <strong>method_missing</strong>(method, *args, &block)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
</h3><div class="docstring">
|
|
460
|
+
<div class="discussion">
|
|
461
|
+
<p>Delegate all methods that aren't defind here to the underlying adapter.</p>
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
</div>
|
|
465
|
+
</div>
|
|
466
|
+
<div class="tags">
|
|
467
|
+
|
|
468
|
+
<p class="tag_title">Since:</p>
|
|
469
|
+
<ul class="since">
|
|
470
|
+
|
|
471
|
+
<li>
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
<div class='inline'><p>0.2.0</p>
|
|
478
|
+
</div>
|
|
479
|
+
|
|
480
|
+
</li>
|
|
481
|
+
|
|
482
|
+
</ul>
|
|
483
|
+
|
|
484
|
+
</div><table class="source_code">
|
|
485
|
+
<tr>
|
|
486
|
+
<td>
|
|
487
|
+
<pre class="lines">
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
222
|
|
491
|
+
223
|
|
492
|
+
224
|
|
493
|
+
225</pre>
|
|
494
|
+
</td>
|
|
495
|
+
<td>
|
|
496
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 222</span>
|
|
497
|
+
|
|
498
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
|
499
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_benchmark'>benchmark</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='ivar'>@adapter</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
|
|
500
|
+
<span class='kw'>super</span>
|
|
501
|
+
<span class='kw'>end</span></pre>
|
|
502
|
+
</td>
|
|
503
|
+
</tr>
|
|
504
|
+
</table>
|
|
505
|
+
</div>
|
|
506
|
+
|
|
507
|
+
</div>
|
|
508
|
+
|
|
509
|
+
<div id="instance_attr_details" class="attr_details">
|
|
510
|
+
<h2>Instance Attribute Details</h2>
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
<span id="tables=-instance_method"></span>
|
|
514
|
+
<div class="method_details first">
|
|
515
|
+
<h3 class="signature first" id="tables-instance_method">
|
|
516
|
+
|
|
517
|
+
- (<tt>Object</tt>) <strong>tables</strong>
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
</h3><div class="docstring">
|
|
524
|
+
<div class="discussion">
|
|
525
|
+
<p>Returns the value of attribute tables</p>
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
</div>
|
|
529
|
+
</div>
|
|
530
|
+
<div class="tags">
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
</div><table class="source_code">
|
|
534
|
+
<tr>
|
|
535
|
+
<td>
|
|
536
|
+
<pre class="lines">
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
8
|
|
540
|
+
9
|
|
541
|
+
10</pre>
|
|
542
|
+
</td>
|
|
543
|
+
<td>
|
|
544
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 8</span>
|
|
545
|
+
|
|
546
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_tables'>tables</span>
|
|
547
|
+
<span class='ivar'>@tables</span>
|
|
548
|
+
<span class='kw'>end</span></pre>
|
|
549
|
+
</td>
|
|
550
|
+
</tr>
|
|
551
|
+
</table>
|
|
552
|
+
</div>
|
|
553
|
+
|
|
554
|
+
</div>
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
<div id="instance_method_details" class="method_details_list">
|
|
558
|
+
<h2>Instance Method Details</h2>
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
<div class="method_details first">
|
|
562
|
+
<h3 class="signature first" id="adapter-instance_method">
|
|
563
|
+
|
|
564
|
+
- (<tt>Object</tt>) <strong>adapter</strong>
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
</h3><div class="docstring">
|
|
571
|
+
<div class="discussion">
|
|
572
|
+
<p>The actual adapter currently in use: presently AwsSdk.</p>
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
</div>
|
|
576
|
+
</div>
|
|
577
|
+
<div class="tags">
|
|
578
|
+
|
|
579
|
+
<p class="tag_title">Since:</p>
|
|
580
|
+
<ul class="since">
|
|
581
|
+
|
|
582
|
+
<li>
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
<div class='inline'><p>0.2.0</p>
|
|
589
|
+
</div>
|
|
590
|
+
|
|
591
|
+
</li>
|
|
592
|
+
|
|
593
|
+
</ul>
|
|
594
|
+
|
|
595
|
+
</div><table class="source_code">
|
|
596
|
+
<tr>
|
|
597
|
+
<td>
|
|
598
|
+
<pre class="lines">
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
13
|
|
602
|
+
14
|
|
603
|
+
15
|
|
604
|
+
16</pre>
|
|
605
|
+
</td>
|
|
606
|
+
<td>
|
|
607
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 13</span>
|
|
608
|
+
|
|
609
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_adapter'>adapter</span>
|
|
610
|
+
<span class='id identifier rubyid_reconnect!'>reconnect!</span> <span class='kw'>unless</span> <span class='ivar'>@adapter</span>
|
|
611
|
+
<span class='ivar'>@adapter</span>
|
|
612
|
+
<span class='kw'>end</span></pre>
|
|
613
|
+
</td>
|
|
614
|
+
</tr>
|
|
615
|
+
</table>
|
|
616
|
+
</div>
|
|
617
|
+
|
|
618
|
+
<div class="method_details ">
|
|
619
|
+
<h3 class="signature " id="benchmark-instance_method">
|
|
620
|
+
|
|
621
|
+
- (<tt>Object</tt>) <strong>benchmark</strong>(method, *args) { ... }
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
</h3><div class="docstring">
|
|
628
|
+
<div class="discussion">
|
|
629
|
+
<p>Shows how long it takes a method to run on the adapter. Useful for generating logged output.</p>
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
</div>
|
|
633
|
+
</div>
|
|
634
|
+
<div class="tags">
|
|
635
|
+
<p class="tag_title">Parameters:</p>
|
|
636
|
+
<ul class="param">
|
|
637
|
+
|
|
638
|
+
<li>
|
|
639
|
+
|
|
640
|
+
<span class='name'>method</span>
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
—
|
|
648
|
+
<div class='inline'><p>the name of the method to appear in the log</p>
|
|
649
|
+
</div>
|
|
650
|
+
|
|
651
|
+
</li>
|
|
652
|
+
|
|
653
|
+
<li>
|
|
654
|
+
|
|
655
|
+
<span class='name'>args</span>
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
—
|
|
663
|
+
<div class='inline'><p>the arguments to the method to appear in the log</p>
|
|
664
|
+
</div>
|
|
665
|
+
|
|
666
|
+
</li>
|
|
667
|
+
|
|
668
|
+
</ul>
|
|
669
|
+
|
|
670
|
+
<p class="tag_title">Yields:</p>
|
|
671
|
+
<ul class="yield">
|
|
672
|
+
|
|
673
|
+
<li>
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
<span class='type'></span>
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
<div class='inline'><p>the actual code to benchmark</p>
|
|
682
|
+
</div>
|
|
683
|
+
|
|
684
|
+
</li>
|
|
685
|
+
|
|
686
|
+
</ul>
|
|
687
|
+
<p class="tag_title">Returns:</p>
|
|
688
|
+
<ul class="return">
|
|
689
|
+
|
|
690
|
+
<li>
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
<span class='type'></span>
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
<div class='inline'><p>the result of the yield</p>
|
|
699
|
+
</div>
|
|
700
|
+
|
|
701
|
+
</li>
|
|
702
|
+
|
|
703
|
+
</ul>
|
|
704
|
+
<p class="tag_title">Since:</p>
|
|
705
|
+
<ul class="since">
|
|
706
|
+
|
|
707
|
+
<li>
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
<div class='inline'><p>0.2.0</p>
|
|
714
|
+
</div>
|
|
715
|
+
|
|
716
|
+
</li>
|
|
717
|
+
|
|
718
|
+
</ul>
|
|
719
|
+
|
|
720
|
+
</div><table class="source_code">
|
|
721
|
+
<tr>
|
|
722
|
+
<td>
|
|
723
|
+
<pre class="lines">
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
37
|
|
727
|
+
38
|
|
728
|
+
39
|
|
729
|
+
40
|
|
730
|
+
41
|
|
731
|
+
42</pre>
|
|
732
|
+
</td>
|
|
733
|
+
<td>
|
|
734
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 37</span>
|
|
735
|
+
|
|
736
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_benchmark'>benchmark</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
|
737
|
+
<span class='id identifier rubyid_start'>start</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span>
|
|
738
|
+
<span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='kw'>yield</span>
|
|
739
|
+
<span class='const'>Dynamoid</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>(</span><span class='embexpr_beg'>#{</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='id identifier rubyid_start'>start</span><span class='rparen'>)</span> <span class='op'>*</span> <span class='float'>1000.0</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_round'>round</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'> ms) </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>_</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:upcase</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'> </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='embexpr_beg'>#{</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> - </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
|
740
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_result'>result</span>
|
|
741
|
+
<span class='kw'>end</span></pre>
|
|
742
|
+
</td>
|
|
743
|
+
</tr>
|
|
744
|
+
</table>
|
|
745
|
+
</div>
|
|
746
|
+
|
|
747
|
+
<div class="method_details ">
|
|
748
|
+
<h3 class="signature " id="delete-instance_method">
|
|
749
|
+
|
|
750
|
+
- (<tt>Object</tt>) <strong>delete</strong>(table, ids, options = {})
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
</h3><div class="docstring">
|
|
757
|
+
<div class="discussion">
|
|
758
|
+
<p>Delete an item from a table. If partitioning is turned on, deletes all partitioned keys as well.</p>
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
</div>
|
|
762
|
+
</div>
|
|
763
|
+
<div class="tags">
|
|
764
|
+
<p class="tag_title">Parameters:</p>
|
|
765
|
+
<ul class="param">
|
|
766
|
+
|
|
767
|
+
<li>
|
|
768
|
+
|
|
769
|
+
<span class='name'>table</span>
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
—
|
|
777
|
+
<div class='inline'><p>the name of the table to write the object to</p>
|
|
778
|
+
</div>
|
|
779
|
+
|
|
780
|
+
</li>
|
|
781
|
+
|
|
782
|
+
<li>
|
|
783
|
+
|
|
784
|
+
<span class='name'>ids</span>
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
—
|
|
792
|
+
<div class='inline'><p>to delete, can also be a string of just one id</p>
|
|
793
|
+
</div>
|
|
794
|
+
|
|
795
|
+
</li>
|
|
796
|
+
|
|
797
|
+
<li>
|
|
798
|
+
|
|
799
|
+
<span class='name'>range_key</span>
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
—
|
|
807
|
+
<div class='inline'><p>of the record to delete, can also be a string of just one range_key</p>
|
|
808
|
+
</div>
|
|
809
|
+
|
|
810
|
+
</li>
|
|
811
|
+
|
|
812
|
+
</ul>
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
</div><table class="source_code">
|
|
816
|
+
<tr>
|
|
817
|
+
<td>
|
|
818
|
+
<pre class="lines">
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
101
|
|
822
|
+
102
|
|
823
|
+
103
|
|
824
|
+
104
|
|
825
|
+
105
|
|
826
|
+
106
|
|
827
|
+
107
|
|
828
|
+
108
|
|
829
|
+
109
|
|
830
|
+
110
|
|
831
|
+
111
|
|
832
|
+
112
|
|
833
|
+
113
|
|
834
|
+
114
|
|
835
|
+
115
|
|
836
|
+
116
|
|
837
|
+
117
|
|
838
|
+
118
|
|
839
|
+
119
|
|
840
|
+
120
|
|
841
|
+
121
|
|
842
|
+
122
|
|
843
|
+
123
|
|
844
|
+
124</pre>
|
|
845
|
+
</td>
|
|
846
|
+
<td>
|
|
847
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 101</span>
|
|
848
|
+
|
|
849
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_ids'>ids</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
850
|
+
<span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:range_key</span><span class='rbracket'>]</span> <span class='comment'>#array of range keys that matches the ids passed in
|
|
851
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:each</span><span class='rparen'>)</span>
|
|
852
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_range_key'>range_key</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:each</span><span class='rparen'>)</span>
|
|
853
|
+
<span class='comment'>#turn ids into array of arrays each element being hash_key, range_key
|
|
854
|
+
</span> <span class='id identifier rubyid_ids'>ids</span> <span class='op'>=</span> <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_each_with_index'>each_with_index</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_id'>id</span><span class='comma'>,</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='comma'>,</span><span class='id identifier rubyid_range_key'>range_key</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rbrace'>}</span>
|
|
855
|
+
<span class='kw'>else</span>
|
|
856
|
+
<span class='id identifier rubyid_ids'>ids</span> <span class='op'>=</span> <span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>?</span> <span class='lbracket'>[</span><span class='lbracket'>[</span><span class='id identifier rubyid_ids'>ids</span><span class='comma'>,</span> <span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_ids'>ids</span>
|
|
857
|
+
<span class='kw'>end</span>
|
|
858
|
+
|
|
859
|
+
<span class='kw'>if</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_partitioning?'>partitioning?</span>
|
|
860
|
+
<span class='id identifier rubyid_batch_delete_item'>batch_delete_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span> <span class='op'>=></span> <span class='id identifier rubyid_id_with_partitions'>id_with_partitions</span><span class='lparen'>(</span><span class='id identifier rubyid_ids'>ids</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
|
861
|
+
<span class='kw'>else</span>
|
|
862
|
+
<span class='id identifier rubyid_batch_delete_item'>batch_delete_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span> <span class='op'>=></span> <span class='id identifier rubyid_ids'>ids</span><span class='rparen'>)</span>
|
|
863
|
+
<span class='kw'>end</span>
|
|
864
|
+
<span class='kw'>else</span>
|
|
865
|
+
<span class='kw'>if</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_partitioning?'>partitioning?</span>
|
|
866
|
+
<span class='id identifier rubyid_ids'>ids</span> <span class='op'>=</span> <span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>?</span> <span class='lbracket'>[</span><span class='lbracket'>[</span><span class='id identifier rubyid_ids'>ids</span><span class='comma'>,</span> <span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_ids'>ids</span>
|
|
867
|
+
<span class='id identifier rubyid_batch_delete_item'>batch_delete_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span> <span class='op'>=></span> <span class='id identifier rubyid_id_with_partitions'>id_with_partitions</span><span class='lparen'>(</span><span class='id identifier rubyid_ids'>ids</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
|
868
|
+
<span class='kw'>else</span>
|
|
869
|
+
<span class='id identifier rubyid_delete_item'>delete_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_ids'>ids</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
870
|
+
<span class='kw'>end</span>
|
|
871
|
+
<span class='kw'>end</span>
|
|
872
|
+
<span class='kw'>end</span></pre>
|
|
873
|
+
</td>
|
|
874
|
+
</tr>
|
|
875
|
+
</table>
|
|
876
|
+
</div>
|
|
877
|
+
|
|
878
|
+
<div class="method_details ">
|
|
879
|
+
<h3 class="signature " id="get_original_id_and_partition-instance_method">
|
|
880
|
+
|
|
881
|
+
- (<tt>String</tt>) <strong>get_original_id_and_partition</strong>(id)
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
</h3><div class="docstring">
|
|
888
|
+
<div class="discussion">
|
|
889
|
+
<p>Get original id (hash_key) and partiton number from a hash_key</p>
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
</div>
|
|
893
|
+
</div>
|
|
894
|
+
<div class="tags">
|
|
895
|
+
<p class="tag_title">Parameters:</p>
|
|
896
|
+
<ul class="param">
|
|
897
|
+
|
|
898
|
+
<li>
|
|
899
|
+
|
|
900
|
+
<span class='name'>id</span>
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
—
|
|
908
|
+
<div class='inline'><p>the id or hash_key of a record, ex. xxxxx.13</p>
|
|
909
|
+
</div>
|
|
910
|
+
|
|
911
|
+
</li>
|
|
912
|
+
|
|
913
|
+
</ul>
|
|
914
|
+
|
|
915
|
+
<p class="tag_title">Returns:</p>
|
|
916
|
+
<ul class="return">
|
|
917
|
+
|
|
918
|
+
<li>
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
<span class='type'>(<tt>String</tt>, <tt>String</tt>)</span>
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
—
|
|
926
|
+
<div class='inline'><p>original_id and the partition number, ex original_id = xxxxx partition = 13</p>
|
|
927
|
+
</div>
|
|
928
|
+
|
|
929
|
+
</li>
|
|
930
|
+
|
|
931
|
+
</ul>
|
|
932
|
+
|
|
933
|
+
</div><table class="source_code">
|
|
934
|
+
<tr>
|
|
935
|
+
<td>
|
|
936
|
+
<pre class="lines">
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
170
|
|
940
|
+
171
|
|
941
|
+
172
|
|
942
|
+
173
|
|
943
|
+
174
|
|
944
|
+
175</pre>
|
|
945
|
+
</td>
|
|
946
|
+
<td>
|
|
947
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 170</span>
|
|
948
|
+
|
|
949
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get_original_id_and_partition'>get_original_id_and_partition</span> <span class='id identifier rubyid_id'>id</span>
|
|
950
|
+
<span class='id identifier rubyid_partition'>partition</span> <span class='op'>=</span> <span class='id identifier rubyid_id'>id</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span>
|
|
951
|
+
<span class='id identifier rubyid_id'>id</span> <span class='op'>=</span> <span class='id identifier rubyid_id'>id</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_partition'>partition</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
|
952
|
+
|
|
953
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_id'>id</span><span class='comma'>,</span> <span class='id identifier rubyid_partition'>partition</span>
|
|
954
|
+
<span class='kw'>end</span></pre>
|
|
955
|
+
</td>
|
|
956
|
+
</tr>
|
|
957
|
+
</table>
|
|
958
|
+
</div>
|
|
959
|
+
|
|
960
|
+
<div class="method_details ">
|
|
961
|
+
<h3 class="signature " id="id_with_partitions-instance_method">
|
|
962
|
+
|
|
963
|
+
- (<tt>Object</tt>) <strong>id_with_partitions</strong>(ids)
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
</h3><div class="docstring">
|
|
970
|
+
<div class="discussion">
|
|
971
|
+
<p>Takes a list of ids and returns them with partitioning added. If an array of arrays is passed, we assume the second key is the range key
|
|
972
|
+
and pass it in unchanged.</p>
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
</div>
|
|
976
|
+
</div>
|
|
977
|
+
<div class="tags">
|
|
978
|
+
|
|
979
|
+
<div class="examples">
|
|
980
|
+
<p class="tag_title">Examples:</p>
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
<p class="example_title"><div class='inline'><p>Partition id 1</p>
|
|
984
|
+
</div></p>
|
|
985
|
+
|
|
986
|
+
<pre class="example code"><code><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_id_with_partitions'>id_with_partitions</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='comment'># ['1.0', '1.1', '1.2', ..., '1.199']</span></code></pre>
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
<p class="example_title"><div class='inline'><p>Partition id 1 and range_key 1.0</p>
|
|
990
|
+
</div></p>
|
|
991
|
+
|
|
992
|
+
<pre class="example code"><code><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_id_with_partitions'>id_with_partitions</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='float'>1.0</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='comment'># [['1.0', 1.0], ['1.1', 1.0], ['1.2', 1.0], ..., ['1.199', 1.0]]</span></code></pre>
|
|
993
|
+
|
|
994
|
+
</div>
|
|
995
|
+
<p class="tag_title">Parameters:</p>
|
|
996
|
+
<ul class="param">
|
|
997
|
+
|
|
998
|
+
<li>
|
|
999
|
+
|
|
1000
|
+
<span class='name'>ids</span>
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
—
|
|
1008
|
+
<div class='inline'><p>array of ids to partition</p>
|
|
1009
|
+
</div>
|
|
1010
|
+
|
|
1011
|
+
</li>
|
|
1012
|
+
|
|
1013
|
+
</ul>
|
|
1014
|
+
|
|
1015
|
+
<p class="tag_title">Since:</p>
|
|
1016
|
+
<ul class="since">
|
|
1017
|
+
|
|
1018
|
+
<li>
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
<div class='inline'><p>0.2.0</p>
|
|
1025
|
+
</div>
|
|
1026
|
+
|
|
1027
|
+
</li>
|
|
1028
|
+
|
|
1029
|
+
</ul>
|
|
1030
|
+
|
|
1031
|
+
</div><table class="source_code">
|
|
1032
|
+
<tr>
|
|
1033
|
+
<td>
|
|
1034
|
+
<pre class="lines">
|
|
1035
|
+
|
|
1036
|
+
|
|
1037
|
+
161
|
|
1038
|
+
162
|
|
1039
|
+
163</pre>
|
|
1040
|
+
</td>
|
|
1041
|
+
<td>
|
|
1042
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 161</span>
|
|
1043
|
+
|
|
1044
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_id_with_partitions'>id_with_partitions</span><span class='lparen'>(</span><span class='id identifier rubyid_ids'>ids</span><span class='rparen'>)</span>
|
|
1045
|
+
<span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_ids'>ids</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_id'>id</span><span class='op'>|</span> <span class='lparen'>(</span><span class='int'>0</span><span class='op'>...</span><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_partition_size'>partition_size</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_id'>id</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Array</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_id'>id</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_n'>n</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_id'>id</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_id'>id</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_n'>n</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
|
|
1046
|
+
<span class='kw'>end</span></pre>
|
|
1047
|
+
</td>
|
|
1048
|
+
</tr>
|
|
1049
|
+
</table>
|
|
1050
|
+
</div>
|
|
1051
|
+
|
|
1052
|
+
<div class="method_details ">
|
|
1053
|
+
<h3 class="signature " id="query-instance_method">
|
|
1054
|
+
|
|
1055
|
+
- (<tt>Array</tt>) <strong>query</strong>(table_name, opts = {})
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
</h3><div class="docstring">
|
|
1062
|
+
<div class="discussion">
|
|
1063
|
+
<p>Query the DynamoDB table. This employs DynamoDB's indexes so is generally faster than scanning, but is
|
|
1064
|
+
only really useful for range queries, since it can only find by one hash key at once. Only provide
|
|
1065
|
+
one range key to the hash. If paritioning is on, will run a query for every parition and join the results</p>
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
</div>
|
|
1069
|
+
</div>
|
|
1070
|
+
<div class="tags">
|
|
1071
|
+
<p class="tag_title">Parameters:</p>
|
|
1072
|
+
<ul class="param">
|
|
1073
|
+
|
|
1074
|
+
<li>
|
|
1075
|
+
|
|
1076
|
+
<span class='name'>table_name</span>
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
—
|
|
1084
|
+
<div class='inline'><p>the name of the table</p>
|
|
1085
|
+
</div>
|
|
1086
|
+
|
|
1087
|
+
</li>
|
|
1088
|
+
|
|
1089
|
+
<li>
|
|
1090
|
+
|
|
1091
|
+
<span class='name'>opts</span>
|
|
1092
|
+
|
|
1093
|
+
|
|
1094
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
—
|
|
1101
|
+
<div class='inline'><p>the options to query the table with</p>
|
|
1102
|
+
</div>
|
|
1103
|
+
|
|
1104
|
+
</li>
|
|
1105
|
+
|
|
1106
|
+
</ul>
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
<p class="tag_title">Options Hash (<tt>opts</tt>):</p>
|
|
1114
|
+
<ul class="option">
|
|
1115
|
+
|
|
1116
|
+
<li>
|
|
1117
|
+
<span class="name">:hash_value</span>
|
|
1118
|
+
<span class="type">(<tt>String</tt>)</span>
|
|
1119
|
+
<span class="default">
|
|
1120
|
+
|
|
1121
|
+
</span>
|
|
1122
|
+
|
|
1123
|
+
— <div class='inline'><p>the value of the hash key to find</p>
|
|
1124
|
+
</div>
|
|
1125
|
+
|
|
1126
|
+
</li>
|
|
1127
|
+
|
|
1128
|
+
<li>
|
|
1129
|
+
<span class="name">:range_value</span>
|
|
1130
|
+
<span class="type">(<tt>Range</tt>)</span>
|
|
1131
|
+
<span class="default">
|
|
1132
|
+
|
|
1133
|
+
</span>
|
|
1134
|
+
|
|
1135
|
+
— <div class='inline'><p>find the range key within this range</p>
|
|
1136
|
+
</div>
|
|
1137
|
+
|
|
1138
|
+
</li>
|
|
1139
|
+
|
|
1140
|
+
<li>
|
|
1141
|
+
<span class="name">:range_greater_than</span>
|
|
1142
|
+
<span class="type">(<tt>Number</tt>)</span>
|
|
1143
|
+
<span class="default">
|
|
1144
|
+
|
|
1145
|
+
</span>
|
|
1146
|
+
|
|
1147
|
+
— <div class='inline'><p>find range keys greater than this</p>
|
|
1148
|
+
</div>
|
|
1149
|
+
|
|
1150
|
+
</li>
|
|
1151
|
+
|
|
1152
|
+
<li>
|
|
1153
|
+
<span class="name">:range_less_than</span>
|
|
1154
|
+
<span class="type">(<tt>Number</tt>)</span>
|
|
1155
|
+
<span class="default">
|
|
1156
|
+
|
|
1157
|
+
</span>
|
|
1158
|
+
|
|
1159
|
+
— <div class='inline'><p>find range keys less than this</p>
|
|
1160
|
+
</div>
|
|
1161
|
+
|
|
1162
|
+
</li>
|
|
1163
|
+
|
|
1164
|
+
<li>
|
|
1165
|
+
<span class="name">:range_gte</span>
|
|
1166
|
+
<span class="type">(<tt>Number</tt>)</span>
|
|
1167
|
+
<span class="default">
|
|
1168
|
+
|
|
1169
|
+
</span>
|
|
1170
|
+
|
|
1171
|
+
— <div class='inline'><p>find range keys greater than or equal to this</p>
|
|
1172
|
+
</div>
|
|
1173
|
+
|
|
1174
|
+
</li>
|
|
1175
|
+
|
|
1176
|
+
<li>
|
|
1177
|
+
<span class="name">:range_lte</span>
|
|
1178
|
+
<span class="type">(<tt>Number</tt>)</span>
|
|
1179
|
+
<span class="default">
|
|
1180
|
+
|
|
1181
|
+
</span>
|
|
1182
|
+
|
|
1183
|
+
— <div class='inline'><p>find range keys less than or equal to this</p>
|
|
1184
|
+
</div>
|
|
1185
|
+
|
|
1186
|
+
</li>
|
|
1187
|
+
|
|
1188
|
+
</ul>
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
<p class="tag_title">Returns:</p>
|
|
1192
|
+
<ul class="return">
|
|
1193
|
+
|
|
1194
|
+
<li>
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
—
|
|
1202
|
+
<div class='inline'><p>an array of all matching items</p>
|
|
1203
|
+
</div>
|
|
1204
|
+
|
|
1205
|
+
</li>
|
|
1206
|
+
|
|
1207
|
+
</ul>
|
|
1208
|
+
|
|
1209
|
+
</div><table class="source_code">
|
|
1210
|
+
<tr>
|
|
1211
|
+
<td>
|
|
1212
|
+
<pre class="lines">
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
242
|
|
1216
|
+
243
|
|
1217
|
+
244
|
|
1218
|
+
245
|
|
1219
|
+
246
|
|
1220
|
+
247
|
|
1221
|
+
248
|
|
1222
|
+
249
|
|
1223
|
+
250
|
|
1224
|
+
251
|
|
1225
|
+
252
|
|
1226
|
+
253
|
|
1227
|
+
254
|
|
1228
|
+
255
|
|
1229
|
+
256
|
|
1230
|
+
257
|
|
1231
|
+
258
|
|
1232
|
+
259
|
|
1233
|
+
260
|
|
1234
|
+
261
|
|
1235
|
+
262
|
|
1236
|
+
263
|
|
1237
|
+
264
|
|
1238
|
+
265</pre>
|
|
1239
|
+
</td>
|
|
1240
|
+
<td>
|
|
1241
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 242</span>
|
|
1242
|
+
|
|
1243
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_query'>query</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
1244
|
+
|
|
1245
|
+
<span class='kw'>unless</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_partitioning?'>partitioning?</span>
|
|
1246
|
+
<span class='comment'>#no paritioning? just pass to the standard query method
|
|
1247
|
+
</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='op'>::</span><span class='const'>AwsSdk</span><span class='period'>.</span><span class='id identifier rubyid_query'>query</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
|
|
1248
|
+
<span class='kw'>else</span>
|
|
1249
|
+
<span class='comment'>#get all the hash_values that could be possible
|
|
1250
|
+
</span> <span class='id identifier rubyid_ids'>ids</span> <span class='op'>=</span> <span class='id identifier rubyid_id_with_partitions'>id_with_partitions</span><span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
|
1251
|
+
|
|
1252
|
+
<span class='comment'>#lets not overwrite with the original options
|
|
1253
|
+
</span> <span class='id identifier rubyid_modified_options'>modified_options</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_clone'>clone</span>
|
|
1254
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
|
1255
|
+
|
|
1256
|
+
<span class='comment'>#loop and query on each of the partition ids
|
|
1257
|
+
</span> <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_id'>id</span><span class='op'>|</span>
|
|
1258
|
+
<span class='id identifier rubyid_modified_options'>modified_options</span><span class='lbracket'>[</span><span class='symbol'>:hash_value</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_id'>id</span>
|
|
1259
|
+
|
|
1260
|
+
<span class='id identifier rubyid_query_result'>query_result</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='op'>::</span><span class='const'>AwsSdk</span><span class='period'>.</span><span class='id identifier rubyid_query'>query</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='comma'>,</span> <span class='id identifier rubyid_modified_options'>modified_options</span><span class='rparen'>)</span>
|
|
1261
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>+=</span> <span class='id identifier rubyid_query_result'>query_result</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_array'>array</span><span class='comma'>,</span> <span class='id identifier rubyid_result'>result</span><span class='op'>|</span> <span class='id identifier rubyid_array'>array</span> <span class='op'>+=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_result'>result</span><span class='rbracket'>]</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_query_result'>query_result</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span>
|
|
1262
|
+
<span class='kw'>end</span>
|
|
1263
|
+
|
|
1264
|
+
<span class='id identifier rubyid_result_for_partition'>result_for_partition</span> <span class='id identifier rubyid_results'>results</span><span class='comma'>,</span> <span class='id identifier rubyid_table_name'>table_name</span>
|
|
1265
|
+
<span class='kw'>end</span>
|
|
1266
|
+
<span class='kw'>end</span></pre>
|
|
1267
|
+
</td>
|
|
1268
|
+
</tr>
|
|
1269
|
+
</table>
|
|
1270
|
+
</div>
|
|
1271
|
+
|
|
1272
|
+
<div class="method_details ">
|
|
1273
|
+
<h3 class="signature " id="read-instance_method">
|
|
1274
|
+
|
|
1275
|
+
- (<tt>Object</tt>) <strong>read</strong>(table, ids, options = {})
|
|
1276
|
+
|
|
1277
|
+
|
|
1278
|
+
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
</h3><div class="docstring">
|
|
1282
|
+
<div class="discussion">
|
|
1283
|
+
<p>Read one or many keys from the selected table. This method intelligently calls batch_get or get on the underlying adapter depending on
|
|
1284
|
+
whether ids is a range or a single key: additionally, if partitioning is enabled, it batch_gets all keys in the partition space
|
|
1285
|
+
automatically. Finally, if a range key is present, it will also interpolate that into the ids so that the batch get will acquire the
|
|
1286
|
+
correct record.</p>
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
</div>
|
|
1290
|
+
</div>
|
|
1291
|
+
<div class="tags">
|
|
1292
|
+
<p class="tag_title">Parameters:</p>
|
|
1293
|
+
<ul class="param">
|
|
1294
|
+
|
|
1295
|
+
<li>
|
|
1296
|
+
|
|
1297
|
+
<span class='name'>table</span>
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
—
|
|
1305
|
+
<div class='inline'><p>the name of the table to write the object to</p>
|
|
1306
|
+
</div>
|
|
1307
|
+
|
|
1308
|
+
</li>
|
|
1309
|
+
|
|
1310
|
+
<li>
|
|
1311
|
+
|
|
1312
|
+
<span class='name'>ids</span>
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
|
|
1319
|
+
—
|
|
1320
|
+
<div class='inline'><p>to fetch, can also be a string of just one id</p>
|
|
1321
|
+
</div>
|
|
1322
|
+
|
|
1323
|
+
</li>
|
|
1324
|
+
|
|
1325
|
+
<li>
|
|
1326
|
+
|
|
1327
|
+
<span class='name'>options:</span>
|
|
1328
|
+
|
|
1329
|
+
|
|
1330
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
1331
|
+
|
|
1332
|
+
|
|
1333
|
+
|
|
1334
|
+
—
|
|
1335
|
+
<div class='inline'><p>Passed to the underlying query. The :range_key option is required whenever the table has a range key,
|
|
1336
|
+
unless multiple ids are passed in and Dynamoid::Config.partitioning? is turned off.</p>
|
|
1337
|
+
</div>
|
|
1338
|
+
|
|
1339
|
+
</li>
|
|
1340
|
+
|
|
1341
|
+
</ul>
|
|
1342
|
+
|
|
1343
|
+
<p class="tag_title">Since:</p>
|
|
1344
|
+
<ul class="since">
|
|
1345
|
+
|
|
1346
|
+
<li>
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
<div class='inline'><p>0.2.0</p>
|
|
1353
|
+
</div>
|
|
1354
|
+
|
|
1355
|
+
</li>
|
|
1356
|
+
|
|
1357
|
+
</ul>
|
|
1358
|
+
|
|
1359
|
+
</div><table class="source_code">
|
|
1360
|
+
<tr>
|
|
1361
|
+
<td>
|
|
1362
|
+
<pre class="lines">
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
72
|
|
1366
|
+
73
|
|
1367
|
+
74
|
|
1368
|
+
75
|
|
1369
|
+
76
|
|
1370
|
+
77
|
|
1371
|
+
78
|
|
1372
|
+
79
|
|
1373
|
+
80
|
|
1374
|
+
81
|
|
1375
|
+
82
|
|
1376
|
+
83
|
|
1377
|
+
84
|
|
1378
|
+
85
|
|
1379
|
+
86
|
|
1380
|
+
87
|
|
1381
|
+
88
|
|
1382
|
+
89
|
|
1383
|
+
90
|
|
1384
|
+
91
|
|
1385
|
+
92
|
|
1386
|
+
93</pre>
|
|
1387
|
+
</td>
|
|
1388
|
+
<td>
|
|
1389
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 72</span>
|
|
1390
|
+
|
|
1391
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_ids'>ids</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
1392
|
+
<span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:range_key</span><span class='rparen'>)</span>
|
|
1393
|
+
|
|
1394
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:each</span><span class='rparen'>)</span>
|
|
1395
|
+
<span class='id identifier rubyid_ids'>ids</span> <span class='op'>=</span> <span class='id identifier rubyid_ids'>ids</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_id'>id</span><span class='op'>|</span> <span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>?</span> <span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='comma'>,</span> <span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_id'>id</span><span class='rbrace'>}</span>
|
|
1396
|
+
<span class='kw'>if</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_partitioning?'>partitioning?</span>
|
|
1397
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='id identifier rubyid_batch_get_item'>batch_get_item</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='id identifier rubyid_table'>table</span> <span class='op'>=></span> <span class='id identifier rubyid_id_with_partitions'>id_with_partitions</span><span class='lparen'>(</span><span class='id identifier rubyid_ids'>ids</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
1398
|
+
<span class='lbrace'>{</span><span class='id identifier rubyid_table'>table</span> <span class='op'>=></span> <span class='id identifier rubyid_result_for_partition'>result_for_partition</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='lbracket'>[</span><span class='id identifier rubyid_table'>table</span><span class='rbracket'>]</span><span class='comma'>,</span><span class='id identifier rubyid_table'>table</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
|
1399
|
+
<span class='kw'>else</span>
|
|
1400
|
+
<span class='id identifier rubyid_batch_get_item'>batch_get_item</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='id identifier rubyid_table'>table</span> <span class='op'>=></span> <span class='id identifier rubyid_ids'>ids</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
1401
|
+
<span class='kw'>end</span>
|
|
1402
|
+
<span class='kw'>else</span>
|
|
1403
|
+
<span class='kw'>if</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_partitioning?'>partitioning?</span>
|
|
1404
|
+
<span class='id identifier rubyid_ids'>ids</span> <span class='op'>=</span> <span class='id identifier rubyid_range_key'>range_key</span> <span class='op'>?</span> <span class='lbracket'>[</span><span class='lbracket'>[</span><span class='id identifier rubyid_ids'>ids</span><span class='comma'>,</span> <span class='id identifier rubyid_range_key'>range_key</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_ids'>ids</span>
|
|
1405
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='id identifier rubyid_batch_get_item'>batch_get_item</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='id identifier rubyid_table'>table</span> <span class='op'>=></span> <span class='id identifier rubyid_id_with_partitions'>id_with_partitions</span><span class='lparen'>(</span><span class='id identifier rubyid_ids'>ids</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
1406
|
+
<span class='id identifier rubyid_result_for_partition'>result_for_partition</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='lbracket'>[</span><span class='id identifier rubyid_table'>table</span><span class='rbracket'>]</span><span class='comma'>,</span><span class='id identifier rubyid_table'>table</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
|
1407
|
+
<span class='kw'>else</span>
|
|
1408
|
+
<span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:range_key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_range_key'>range_key</span> <span class='kw'>if</span> <span class='id identifier rubyid_range_key'>range_key</span>
|
|
1409
|
+
<span class='id identifier rubyid_get_item'>get_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_ids'>ids</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
1410
|
+
<span class='kw'>end</span>
|
|
1411
|
+
<span class='kw'>end</span>
|
|
1412
|
+
<span class='kw'>end</span></pre>
|
|
1413
|
+
</td>
|
|
1414
|
+
</tr>
|
|
1415
|
+
</table>
|
|
1416
|
+
</div>
|
|
1417
|
+
|
|
1418
|
+
<div class="method_details ">
|
|
1419
|
+
<h3 class="signature " id="reconnect!-instance_method">
|
|
1420
|
+
|
|
1421
|
+
- (<tt>Object</tt>) <strong>reconnect!</strong>
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
</h3><div class="docstring">
|
|
1428
|
+
<div class="discussion">
|
|
1429
|
+
<p>Establishes a connection to the underyling adapter and caches all its tables for speedier future lookups. Issued when the adapter is first called.</p>
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
</div>
|
|
1433
|
+
</div>
|
|
1434
|
+
<div class="tags">
|
|
1435
|
+
|
|
1436
|
+
<p class="tag_title">Since:</p>
|
|
1437
|
+
<ul class="since">
|
|
1438
|
+
|
|
1439
|
+
<li>
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
<div class='inline'><p>0.2.0</p>
|
|
1446
|
+
</div>
|
|
1447
|
+
|
|
1448
|
+
</li>
|
|
1449
|
+
|
|
1450
|
+
</ul>
|
|
1451
|
+
|
|
1452
|
+
</div><table class="source_code">
|
|
1453
|
+
<tr>
|
|
1454
|
+
<td>
|
|
1455
|
+
<pre class="lines">
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
21
|
|
1459
|
+
22
|
|
1460
|
+
23
|
|
1461
|
+
24
|
|
1462
|
+
25
|
|
1463
|
+
26</pre>
|
|
1464
|
+
</td>
|
|
1465
|
+
<td>
|
|
1466
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 21</span>
|
|
1467
|
+
|
|
1468
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_reconnect!'>reconnect!</span>
|
|
1469
|
+
<span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>dynamoid/adapter/</span><span class='embexpr_beg'>#{</span><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_adapter'>adapter</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_const_defined?'>const_defined?</span><span class='lparen'>(</span><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_camelcase'>camelcase</span><span class='rparen'>)</span>
|
|
1470
|
+
<span class='ivar'>@adapter</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_camelcase'>camelcase</span><span class='rparen'>)</span>
|
|
1471
|
+
<span class='ivar'>@adapter</span><span class='period'>.</span><span class='id identifier rubyid_connect!'>connect!</span> <span class='kw'>if</span> <span class='ivar'>@adapter</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:connect!</span><span class='rparen'>)</span>
|
|
1472
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_tables'>tables</span> <span class='op'>=</span> <span class='id identifier rubyid_benchmark'>benchmark</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Cache Tables</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='id identifier rubyid_list_tables'>list_tables</span><span class='rbrace'>}</span>
|
|
1473
|
+
<span class='kw'>end</span></pre>
|
|
1474
|
+
</td>
|
|
1475
|
+
</tr>
|
|
1476
|
+
</table>
|
|
1477
|
+
</div>
|
|
1478
|
+
|
|
1479
|
+
<div class="method_details ">
|
|
1480
|
+
<h3 class="signature " id="result_for_partition-instance_method">
|
|
1481
|
+
|
|
1482
|
+
- (<tt>Object</tt>) <strong>result_for_partition</strong>(results, table_name)
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
</h3><div class="docstring">
|
|
1489
|
+
<div class="discussion">
|
|
1490
|
+
<p>Takes an array of query results that are partitioned, find the most recently updated ones that share an id and range_key, and return only the most recently updated. Compares each result by
|
|
1491
|
+
their id and updated_at attributes; if the updated_at is the greatest, then it must be the correct result.</p>
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
</div>
|
|
1495
|
+
</div>
|
|
1496
|
+
<div class="tags">
|
|
1497
|
+
<p class="tag_title">Parameters:</p>
|
|
1498
|
+
<ul class="param">
|
|
1499
|
+
|
|
1500
|
+
<li>
|
|
1501
|
+
|
|
1502
|
+
<span class='name'>returned</span>
|
|
1503
|
+
|
|
1504
|
+
|
|
1505
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
—
|
|
1510
|
+
<div class='inline'><p>partitioned results from a query</p>
|
|
1511
|
+
</div>
|
|
1512
|
+
|
|
1513
|
+
</li>
|
|
1514
|
+
|
|
1515
|
+
<li>
|
|
1516
|
+
|
|
1517
|
+
<span class='name'>table_name</span>
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
—
|
|
1525
|
+
<div class='inline'><p>the name of the table</p>
|
|
1526
|
+
</div>
|
|
1527
|
+
|
|
1528
|
+
</li>
|
|
1529
|
+
|
|
1530
|
+
</ul>
|
|
1531
|
+
|
|
1532
|
+
<p class="tag_title">Since:</p>
|
|
1533
|
+
<ul class="since">
|
|
1534
|
+
|
|
1535
|
+
<li>
|
|
1536
|
+
|
|
1537
|
+
|
|
1538
|
+
|
|
1539
|
+
|
|
1540
|
+
|
|
1541
|
+
<div class='inline'><p>0.2.0</p>
|
|
1542
|
+
</div>
|
|
1543
|
+
|
|
1544
|
+
</li>
|
|
1545
|
+
|
|
1546
|
+
</ul>
|
|
1547
|
+
|
|
1548
|
+
</div><table class="source_code">
|
|
1549
|
+
<tr>
|
|
1550
|
+
<td>
|
|
1551
|
+
<pre class="lines">
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
184
|
|
1555
|
+
185
|
|
1556
|
+
186
|
|
1557
|
+
187
|
|
1558
|
+
188
|
|
1559
|
+
189
|
|
1560
|
+
190
|
|
1561
|
+
191
|
|
1562
|
+
192
|
|
1563
|
+
193
|
|
1564
|
+
194
|
|
1565
|
+
195
|
|
1566
|
+
196
|
|
1567
|
+
197
|
|
1568
|
+
198
|
|
1569
|
+
199
|
|
1570
|
+
200
|
|
1571
|
+
201
|
|
1572
|
+
202
|
|
1573
|
+
203
|
|
1574
|
+
204
|
|
1575
|
+
205
|
|
1576
|
+
206
|
|
1577
|
+
207
|
|
1578
|
+
208
|
|
1579
|
+
209
|
|
1580
|
+
210
|
|
1581
|
+
211
|
|
1582
|
+
212
|
|
1583
|
+
213
|
|
1584
|
+
214
|
|
1585
|
+
215
|
|
1586
|
+
216
|
|
1587
|
+
217</pre>
|
|
1588
|
+
</td>
|
|
1589
|
+
<td>
|
|
1590
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 184</span>
|
|
1591
|
+
|
|
1592
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_result_for_partition'>result_for_partition</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='comma'>,</span> <span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
|
1593
|
+
<span class='id identifier rubyid_table'>table</span> <span class='op'>=</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Adapter</span><span class='op'>::</span><span class='const'>AwsSdk</span><span class='period'>.</span><span class='id identifier rubyid_get_table'>get_table</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
|
1594
|
+
|
|
1595
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_range_key'>range_key</span>
|
|
1596
|
+
<span class='id identifier rubyid_range_key_name'>range_key_name</span> <span class='op'>=</span> <span class='id identifier rubyid_table'>table</span><span class='period'>.</span><span class='id identifier rubyid_range_key'>range_key</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
|
|
1597
|
+
|
|
1598
|
+
<span class='id identifier rubyid_final_hash'>final_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
|
1599
|
+
|
|
1600
|
+
<span class='id identifier rubyid_results'>results</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_record'>record</span><span class='op'>|</span>
|
|
1601
|
+
<span class='id identifier rubyid_test_record'>test_record</span> <span class='op'>=</span> <span class='id identifier rubyid_final_hash'>final_hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key_name'>range_key_name</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
|
|
1602
|
+
|
|
1603
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_test_record'>test_record</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key_name'>range_key_name</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_test_record'>test_record</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key_name'>range_key_name</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='lparen'>(</span><span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='symbol'>:updated_at</span><span class='rbracket'>]</span> <span class='op'>></span> <span class='id identifier rubyid_test_record'>test_record</span><span class='lbracket'>[</span><span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
|
1604
|
+
<span class='comment'>#get ride of our partition and put it in the array with the range key
|
|
1605
|
+
</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_partition'>partition</span> <span class='op'>=</span> <span class='id identifier rubyid_get_original_id_and_partition'>get_original_id_and_partition</span> <span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span>
|
|
1606
|
+
<span class='id identifier rubyid_final_hash'>final_hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_record'>record</span><span class='lbracket'>[</span><span class='id identifier rubyid_range_key_name'>range_key_name</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_record'>record</span>
|
|
1607
|
+
<span class='kw'>end</span>
|
|
1608
|
+
<span class='kw'>end</span>
|
|
1609
|
+
|
|
1610
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_final_hash'>final_hash</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span>
|
|
1611
|
+
<span class='kw'>else</span>
|
|
1612
|
+
<span class='lbrace'>{</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='op'>|</span>
|
|
1613
|
+
<span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_result'>result</span><span class='op'>|</span>
|
|
1614
|
+
<span class='kw'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
|
1615
|
+
<span class='comment'>#Need to find the value of id with out the . and partition number
|
|
1616
|
+
</span> <span class='id identifier rubyid_id'>id</span><span class='comma'>,</span> <span class='id identifier rubyid_partition'>partition</span> <span class='op'>=</span> <span class='id identifier rubyid_get_original_id_and_partition'>get_original_id_and_partition</span> <span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span>
|
|
1617
|
+
|
|
1618
|
+
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='symbol'>:updated_at</span><span class='rbracket'>]</span> <span class='op'>></span> <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:updated_at</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
|
1619
|
+
<span class='id identifier rubyid_result'>result</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_id'>id</span>
|
|
1620
|
+
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span>
|
|
1621
|
+
<span class='kw'>end</span>
|
|
1622
|
+
<span class='kw'>end</span>
|
|
1623
|
+
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span>
|
|
1624
|
+
<span class='kw'>end</span>
|
|
1625
|
+
<span class='kw'>end</span></pre>
|
|
1626
|
+
</td>
|
|
1627
|
+
</tr>
|
|
1628
|
+
</table>
|
|
1629
|
+
</div>
|
|
1630
|
+
|
|
1631
|
+
<div class="method_details ">
|
|
1632
|
+
<h3 class="signature " id="scan-instance_method">
|
|
1633
|
+
|
|
1634
|
+
- (<tt>Object</tt>) <strong>scan</strong>(table, query, opts = {})
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
|
|
1639
|
+
|
|
1640
|
+
</h3><div class="docstring">
|
|
1641
|
+
<div class="discussion">
|
|
1642
|
+
<p>Scans a table. Generally quite slow; try to avoid using scan if at all possible.</p>
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
</div>
|
|
1646
|
+
</div>
|
|
1647
|
+
<div class="tags">
|
|
1648
|
+
<p class="tag_title">Parameters:</p>
|
|
1649
|
+
<ul class="param">
|
|
1650
|
+
|
|
1651
|
+
<li>
|
|
1652
|
+
|
|
1653
|
+
<span class='name'>table</span>
|
|
1654
|
+
|
|
1655
|
+
|
|
1656
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1657
|
+
|
|
1658
|
+
|
|
1659
|
+
|
|
1660
|
+
—
|
|
1661
|
+
<div class='inline'><p>the name of the table to write the object to</p>
|
|
1662
|
+
</div>
|
|
1663
|
+
|
|
1664
|
+
</li>
|
|
1665
|
+
|
|
1666
|
+
<li>
|
|
1667
|
+
|
|
1668
|
+
<span class='name'>scan_hash</span>
|
|
1669
|
+
|
|
1670
|
+
|
|
1671
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
1672
|
+
|
|
1673
|
+
|
|
1674
|
+
|
|
1675
|
+
—
|
|
1676
|
+
<div class='inline'><p>a hash of attributes: matching records will be returned by the scan</p>
|
|
1677
|
+
</div>
|
|
1678
|
+
|
|
1679
|
+
</li>
|
|
1680
|
+
|
|
1681
|
+
</ul>
|
|
1682
|
+
|
|
1683
|
+
<p class="tag_title">Since:</p>
|
|
1684
|
+
<ul class="since">
|
|
1685
|
+
|
|
1686
|
+
<li>
|
|
1687
|
+
|
|
1688
|
+
|
|
1689
|
+
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
<div class='inline'><p>0.2.0</p>
|
|
1693
|
+
</div>
|
|
1694
|
+
|
|
1695
|
+
</li>
|
|
1696
|
+
|
|
1697
|
+
</ul>
|
|
1698
|
+
|
|
1699
|
+
</div><table class="source_code">
|
|
1700
|
+
<tr>
|
|
1701
|
+
<td>
|
|
1702
|
+
<pre class="lines">
|
|
1703
|
+
|
|
1704
|
+
|
|
1705
|
+
132
|
|
1706
|
+
133
|
|
1707
|
+
134
|
|
1708
|
+
135
|
|
1709
|
+
136
|
|
1710
|
+
137
|
|
1711
|
+
138
|
|
1712
|
+
139</pre>
|
|
1713
|
+
</td>
|
|
1714
|
+
<td>
|
|
1715
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 132</span>
|
|
1716
|
+
|
|
1717
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
1718
|
+
<span class='kw'>if</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_partitioning?'>partitioning?</span>
|
|
1719
|
+
<span class='id identifier rubyid_results'>results</span> <span class='op'>=</span> <span class='id identifier rubyid_benchmark'>benchmark</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Scan</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
|
1720
|
+
<span class='id identifier rubyid_result_for_partition'>result_for_partition</span><span class='lparen'>(</span><span class='id identifier rubyid_results'>results</span><span class='comma'>,</span><span class='id identifier rubyid_table'>table</span><span class='rparen'>)</span>
|
|
1721
|
+
<span class='kw'>else</span>
|
|
1722
|
+
<span class='id identifier rubyid_benchmark'>benchmark</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Scan</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
|
1723
|
+
<span class='kw'>end</span>
|
|
1724
|
+
<span class='kw'>end</span></pre>
|
|
1725
|
+
</td>
|
|
1726
|
+
</tr>
|
|
1727
|
+
</table>
|
|
1728
|
+
</div>
|
|
1729
|
+
|
|
1730
|
+
<div class="method_details ">
|
|
1731
|
+
<h3 class="signature " id="write-instance_method">
|
|
1732
|
+
|
|
1733
|
+
- (<tt>Object</tt>) <strong>write</strong>(table, object, options = nil)
|
|
1734
|
+
|
|
1735
|
+
|
|
1736
|
+
|
|
1737
|
+
|
|
1738
|
+
|
|
1739
|
+
</h3><div class="docstring">
|
|
1740
|
+
<div class="discussion">
|
|
1741
|
+
<p>Write an object to the adapter. Partition it to a randomly selected key first if necessary.</p>
|
|
1742
|
+
|
|
1743
|
+
|
|
1744
|
+
</div>
|
|
1745
|
+
</div>
|
|
1746
|
+
<div class="tags">
|
|
1747
|
+
<p class="tag_title">Parameters:</p>
|
|
1748
|
+
<ul class="param">
|
|
1749
|
+
|
|
1750
|
+
<li>
|
|
1751
|
+
|
|
1752
|
+
<span class='name'>table</span>
|
|
1753
|
+
|
|
1754
|
+
|
|
1755
|
+
<span class='type'>(<tt>String</tt>)</span>
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
|
|
1759
|
+
—
|
|
1760
|
+
<div class='inline'><p>the name of the table to write the object to</p>
|
|
1761
|
+
</div>
|
|
1762
|
+
|
|
1763
|
+
</li>
|
|
1764
|
+
|
|
1765
|
+
<li>
|
|
1766
|
+
|
|
1767
|
+
<span class='name'>object</span>
|
|
1768
|
+
|
|
1769
|
+
|
|
1770
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
—
|
|
1775
|
+
<div class='inline'><p>the object itself</p>
|
|
1776
|
+
</div>
|
|
1777
|
+
|
|
1778
|
+
</li>
|
|
1779
|
+
|
|
1780
|
+
<li>
|
|
1781
|
+
|
|
1782
|
+
<span class='name'>options</span>
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
—
|
|
1792
|
+
<div class='inline'><p>Options that are passed to the put_item call</p>
|
|
1793
|
+
</div>
|
|
1794
|
+
|
|
1795
|
+
</li>
|
|
1796
|
+
|
|
1797
|
+
</ul>
|
|
1798
|
+
|
|
1799
|
+
<p class="tag_title">Returns:</p>
|
|
1800
|
+
<ul class="return">
|
|
1801
|
+
|
|
1802
|
+
<li>
|
|
1803
|
+
|
|
1804
|
+
|
|
1805
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
|
|
1809
|
+
—
|
|
1810
|
+
<div class='inline'><p>the persisted object</p>
|
|
1811
|
+
</div>
|
|
1812
|
+
|
|
1813
|
+
</li>
|
|
1814
|
+
|
|
1815
|
+
</ul>
|
|
1816
|
+
<p class="tag_title">Since:</p>
|
|
1817
|
+
<ul class="since">
|
|
1818
|
+
|
|
1819
|
+
<li>
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
<div class='inline'><p>0.2.0</p>
|
|
1826
|
+
</div>
|
|
1827
|
+
|
|
1828
|
+
</li>
|
|
1829
|
+
|
|
1830
|
+
</ul>
|
|
1831
|
+
|
|
1832
|
+
</div><table class="source_code">
|
|
1833
|
+
<tr>
|
|
1834
|
+
<td>
|
|
1835
|
+
<pre class="lines">
|
|
1836
|
+
|
|
1837
|
+
|
|
1838
|
+
53
|
|
1839
|
+
54
|
|
1840
|
+
55
|
|
1841
|
+
56
|
|
1842
|
+
57
|
|
1843
|
+
58
|
|
1844
|
+
59</pre>
|
|
1845
|
+
</td>
|
|
1846
|
+
<td>
|
|
1847
|
+
<pre class="code"><span class="info file"># File 'lib/dynamoid/adapter.rb', line 53</span>
|
|
1848
|
+
|
|
1849
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_object'>object</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
|
1850
|
+
<span class='kw'>if</span> <span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_partitioning?'>partitioning?</span> <span class='op'>&&</span> <span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span>
|
|
1851
|
+
<span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='const'>Random</span><span class='period'>.</span><span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='const'>Dynamoid</span><span class='op'>::</span><span class='const'>Config</span><span class='period'>.</span><span class='id identifier rubyid_partition_size'>partition_size</span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
|
1852
|
+
<span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='symbol'>:updated_at</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span>
|
|
1853
|
+
<span class='kw'>end</span>
|
|
1854
|
+
<span class='id identifier rubyid_put_item'>put_item</span><span class='lparen'>(</span><span class='id identifier rubyid_table'>table</span><span class='comma'>,</span> <span class='id identifier rubyid_object'>object</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
1855
|
+
<span class='kw'>end</span></pre>
|
|
1856
|
+
</td>
|
|
1857
|
+
</tr>
|
|
1858
|
+
</table>
|
|
1859
|
+
</div>
|
|
1860
|
+
|
|
1861
|
+
</div>
|
|
1862
|
+
|
|
1863
|
+
</div>
|
|
1864
|
+
|
|
1865
|
+
<div id="footer">
|
|
1866
|
+
Generated on Thu Jun 27 21:59:10 2013 by
|
|
1867
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1868
|
+
0.8.6.1 (ruby-1.9.3).
|
|
1869
|
+
</div>
|
|
1870
|
+
|
|
1871
|
+
</body>
|
|
1872
|
+
</html>
|