dynamoid 1.1.0 → 1.2.0

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.
@@ -16,7 +16,15 @@ module Dynamoid
16
16
  module ClassMethods
17
17
 
18
18
  def table_name
19
- @table_name ||= "#{Dynamoid::Config.namespace}_#{options[:name] || base_class.name.split('::').last.downcase.pluralize}"
19
+ table_base_name = options[:name] || base_class.name.split('::').last
20
+ .downcase.pluralize
21
+ table_prefix = if Dynamoid::Config.namespace.nil? then
22
+ ''
23
+ else
24
+ "#{Dynamoid::Config.namespace}_"
25
+ end
26
+
27
+ @table_name ||= "#{table_prefix}#{table_base_name}"
20
28
  end
21
29
 
22
30
  # Creates a table.
@@ -27,7 +35,7 @@ module Dynamoid
27
35
  # @option options [Integer] :read_capacity set the read capacity for the table; does not work on existing tables
28
36
  # @option options [Integer] :write_capacity set the write capacity for the table; does not work on existing tables
29
37
  # @option options [Hash] {range_key => :type} a hash of the name of the range key and a symbol of its type
30
- #
38
+ # @option options [Symbol] :hash_key_type the dynamo type of the hash key (:string or :number)
31
39
  # @since 0.4.0
32
40
  def create_table(options = {})
33
41
  if self.range_key
@@ -40,7 +48,10 @@ module Dynamoid
40
48
  :table_name => self.table_name,
41
49
  :write_capacity => self.write_capacity,
42
50
  :read_capacity => self.read_capacity,
43
- :range_key => range_key_hash
51
+ :range_key => range_key_hash,
52
+ :hash_key_type => dynamo_type(attributes[self.hash_key][:type]),
53
+ :local_secondary_indexes => self.local_secondary_indexes.values,
54
+ :global_secondary_indexes => self.global_secondary_indexes.values
44
55
  }.merge(options)
45
56
 
46
57
  Dynamoid.adapter.create_table(options[:table_name], options[:id], options)
@@ -32,5 +32,32 @@ module Dynamoid
32
32
  raise Dynamoid::Errors::DocumentNotValid.new(self) unless valid?
33
33
  save(:validate => false)
34
34
  end
35
+
36
+ module ClassMethods
37
+
38
+ # Override validates_presence_of to handle false values as present.
39
+ #
40
+ # @since 1.1.1
41
+ def validates_presence_of(*attr_names)
42
+ validates_with PresenceValidator, _merge_attributes(attr_names)
43
+ end
44
+
45
+ private
46
+
47
+ # Validates that the specified attributes are present (false or not blank).
48
+ class PresenceValidator < ActiveModel::EachValidator
49
+ # Validate the record for the record and value.
50
+ def validate_each(record, attr_name, value)
51
+ record.errors.add(attr_name, :blank, options) if not_present?(value)
52
+ end
53
+
54
+ private
55
+
56
+ # Check whether a value is not present.
57
+ def not_present?(value)
58
+ value.blank? && value != false
59
+ end
60
+ end
61
+ end
35
62
  end
36
63
  end
@@ -0,0 +1,3 @@
1
+ module Dynamoid
2
+ VERSION = "1.2.0"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Symonds
@@ -13,10 +13,14 @@ authors:
13
13
  - Stefan Neculai
14
14
  - Philip White
15
15
  - Peeyush Kumar
16
+ - Sumanth Ravipati
17
+ - Pascal Corpet
18
+ - Brian Glusman
19
+ - Peter Boling
16
20
  autorequire:
17
- bindir: bin
21
+ bindir: exe
18
22
  cert_chain: []
19
- date: 2015-12-30 00:00:00.000000000 Z
23
+ date: 2016-09-04 00:00:00.000000000 Z
20
24
  dependencies:
21
25
  - !ruby/object:Gem::Dependency
22
26
  name: activemodel
@@ -66,42 +70,42 @@ dependencies:
66
70
  requirements:
67
71
  - - ">="
68
72
  - !ruby/object:Gem::Version
69
- version: '0'
73
+ version: '10'
70
74
  type: :development
71
75
  prerelease: false
72
76
  version_requirements: !ruby/object:Gem::Requirement
73
77
  requirements:
74
78
  - - ">="
75
79
  - !ruby/object:Gem::Version
76
- version: '0'
80
+ version: '10'
77
81
  - !ruby/object:Gem::Dependency
78
- name: rspec
82
+ name: bundler
79
83
  requirement: !ruby/object:Gem::Requirement
80
84
  requirements:
81
85
  - - "~>"
82
86
  - !ruby/object:Gem::Version
83
- version: '3'
87
+ version: '1.12'
84
88
  type: :development
85
89
  prerelease: false
86
90
  version_requirements: !ruby/object:Gem::Requirement
87
91
  requirements:
88
92
  - - "~>"
89
93
  - !ruby/object:Gem::Version
90
- version: '3'
94
+ version: '1.12'
91
95
  - !ruby/object:Gem::Dependency
92
- name: bundler
96
+ name: rspec
93
97
  requirement: !ruby/object:Gem::Requirement
94
98
  requirements:
95
99
  - - ">="
96
100
  - !ruby/object:Gem::Version
97
- version: '0'
101
+ version: '3'
98
102
  type: :development
99
103
  prerelease: false
100
104
  version_requirements: !ruby/object:Gem::Requirement
101
105
  requirements:
102
106
  - - ">="
103
107
  - !ruby/object:Gem::Version
104
- version: '0'
108
+ version: '3'
105
109
  - !ruby/object:Gem::Dependency
106
110
  name: yard
107
111
  requirement: !ruby/object:Gem::Requirement
@@ -158,20 +162,40 @@ dependencies:
158
162
  - - ">="
159
163
  - !ruby/object:Gem::Version
160
164
  version: '0'
165
+ - !ruby/object:Gem::Dependency
166
+ name: rspec-retry
167
+ requirement: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ type: :development
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
161
179
  description: Dynamoid is an ORM for Amazon's DynamoDB that supports offline development,
162
180
  associations, querying, and everything else you'd expect from an ActiveRecord-style
163
181
  replacement.
164
- email:
182
+ email:
183
+ - peter.boling@gmail.com
184
+ - brian@stellaservice.com
165
185
  executables: []
166
186
  extensions: []
167
187
  extra_rdoc_files:
168
188
  - LICENSE.txt
169
- - README.markdown
189
+ - README.md
170
190
  files:
191
+ - ".document"
192
+ - ".gitignore"
193
+ - ".rspec"
194
+ - ".travis.yml"
171
195
  - CHANGELOG.md
172
196
  - Gemfile
173
197
  - LICENSE.txt
174
- - README.markdown
198
+ - README.md
175
199
  - Rakefile
176
200
  - dynamoid.gemspec
177
201
  - lib/dynamoid.rb
@@ -196,9 +220,11 @@ files:
196
220
  - lib/dynamoid/fields.rb
197
221
  - lib/dynamoid/finders.rb
198
222
  - lib/dynamoid/identity_map.rb
223
+ - lib/dynamoid/indexes.rb
199
224
  - lib/dynamoid/middleware/identity_map.rb
200
225
  - lib/dynamoid/persistence.rb
201
226
  - lib/dynamoid/validations.rb
227
+ - lib/dynamoid/version.rb
202
228
  homepage: http://github.com/Dynamoid/Dynamoid
203
229
  licenses:
204
230
  - MIT
@@ -219,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
245
  version: '0'
220
246
  requirements: []
221
247
  rubyforge_project:
222
- rubygems_version: 2.5.1
248
+ rubygems_version: 2.4.8
223
249
  signing_key:
224
250
  specification_version: 4
225
251
  summary: Dynamoid is an ORM for Amazon's DynamoDB