ocean-dynamo 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09fc89d897d34e016dd0178202cfcf7efb05b996
4
- data.tar.gz: b6b27446ce89451319caa15b5f8aa386e0c7d6f9
3
+ metadata.gz: ec5cc85dff191d7167a21eb63097edebd85390b4
4
+ data.tar.gz: 26d74600e6253dfa77c4bbd3a66be11bf03e5130
5
5
  SHA512:
6
- metadata.gz: 2089ddfeef6c9d4b018d42a4634a4d2a3b9c9bb23fc40bdb669aae91933deb183703acd7a5c2feaafbdb05faa4c63e778d04dfc89f4fcd25ed1a5a66ef53d883
7
- data.tar.gz: 04f26407611385c332655415475e7ff012743c208512bb0e4e0772ce72dd3af92f321f65561f2f55759dd0913b0ee621f1fd7dfe5fd4aa93a25e1b8e6e7e19c9
6
+ metadata.gz: 1b192785b2e8f0befeb1241154a0c1d652d6511a13cb44d12b940beedbb13f05685a5791e2cbecd1abccf883da51a95bb6a8219ade4f7cb915ff4b6e3ee6b338
7
+ data.tar.gz: 8d00dccf68667873f1a2173198969923307d8285f74ce59ed8ffeacbfa80bafb8b4310aeb1c0fb227d0adc5f79fdffb6cab7e3f89bc7fb0a8538ef297369fe54
@@ -17,19 +17,18 @@ OceanDynamo requires Ruby 2.0 and Ruby on Rails 4.0.0 or later.
17
17
 
18
18
  As one important use case for OceanDynamo is to facilitate the conversion of SQL based
19
19
  ActiveRecord models to DynamoDB based models, it is important that the syntax and semantics
20
- of OceanDynamo's operations are as close as possible to those of ActiveRecord. This means
21
- that all callbacks should be available, before, around and after, and that they should be
22
- called in the same order as in ActiveRecord. OceanDynamo follows this pattern closely and
20
+ of OceanDynamo's operations are as close as possible to those of ActiveRecord, including
21
+ callbacks, exceptions and support methods. Ocean-dynamo follows this pattern closely and
23
22
  is of course based on ActiveModel.
24
23
 
25
24
  The attribute and persistence layer of OceanDynamo is modeled on that of ActiveRecord:
26
- there's +save+, +save!+, +create+, +update+, +update!+, +update_attribute+ and all the other
25
+ there's +save+, +save!+, +create+, +update+, +update!+, +update_attributes+ and all the other
27
26
  methods you're used to. The design goal is always to implement as much as possible of the
28
- ActiveRecord interface, without sacrificing scalability. This makes the task of switching from
29
- SQL to no-SQL much easier.
27
+ ActiveRecord interface, without sacrificing scalability. This makes the task of switching
28
+ from SQL to no-SQL much easier.
30
29
 
31
- Due to its similarity to ActiveRecord, OceanDynamo works with FactoryGirl.
32
- Furthermore, future versions will keep track of and delete instances after tests.
30
+ Thanks to its structural similarity to ActiveRecord, OceanDynamo works with FactoryGirl.
31
+ To facilitate testing, future versions will keep track of and delete instances after tests.
33
32
 
34
33
  OceanDynamo will use secondary indices to retrieve related table items,
35
34
  which means it will scale without limits.
@@ -61,37 +60,40 @@ The following example shows the syntax.
61
60
 
62
61
  end
63
62
 
64
- Each attribute has a name, a type (:string, :integer, :float, :datetime, :boolean, or
65
- :serialized) where :string is the default. Each attribute also optionally has a default
66
- value, which can be a Proc. The hash key attribute is by default :uuid (this can of
67
- course be specified) and is a :string. The keys can also be explicitly declared.
63
+ Each attribute has a name, a type (+:string+, +:integer+, +:float+, +:datetime+, +:boolean+,
64
+ or +:serialized+) where +:string+ is the default. Each attribute also optionally has a default
65
+ value, which can be a Proc. The hash key attribute is by default +:uuid+ (this can of
66
+ course be specified) and is a +:string+. The keys can also be explicitly declared.
68
67
 
69
- The :string, :integer, :float and :datetime types can also store sets of their type.
70
- Sets are represented as arrays and may not contain duplicates and may not be empty.
68
+ The +:string+, +:integer+, +:float+ and +:datetime+ types can also store sets of their type.
69
+ Sets are represented as arrays, may not contain duplicates and may not be empty.
71
70
 
72
- All attributes except the :string type can take the value nil. Storing nil for a string
73
- value will return the empty string, "".
71
+ All attributes except the +:string+ type can take the value +nil+. Storing +nil+ for a string
72
+ value will return the empty string, <tt>""</tt>.
74
73
 
75
74
  Also, dynamo_schema takes args and many options. Here's the full syntax:
76
75
 
77
76
  dynamo_schema(
78
- table_hash_key = :uuid,
79
- table_range_key = nil,
80
- table_name: compute_table_name,
81
- table_name_prefix: nil,
82
- table_name_suffix: nil,
83
- read_capacity_units: 10,
84
- write_capacity_units: 5,
85
- connect: :late,
86
- create: false,
87
- locking: :lock_version,
88
- timestamps: [:created_at, :updated_at],
89
- &block
90
- )
77
+ table_hash_key = :uuid, # The name of the hash key attribute
78
+ table_range_key = nil, # The name of the range key attribute (or nil)
79
+ table_name: compute_table_name, # The basename of the DynamoDB table
80
+ table_name_prefix: nil, # A basename prefix string or nil
81
+ table_name_suffix: nil, # A basename suffix string or nil
82
+ read_capacity_units: 10, # Used only when creating a table
83
+ write_capacity_units: 5, # Used only when creating a table
84
+ connect: :late, # true, :late, nil/false
85
+ create: false, # If true, create the table if nonexistent
86
+ locking: :lock_version, # The name of the lock attribute or nil/false
87
+ timestamps: [:created_at, :updated_at] # An array of timestamp columns or nil/false
88
+ ) do
89
+ # Attribute definitions
90
+ ...
91
+ ...
92
+ end
91
93
 
92
94
  At the moment, OceanDynamo is fully usable as an ActiveModel and can be used by Rails
93
95
  controllers. Furthermore, OceanDynamo implements much of the infrastructure of ActiveRecord;
94
- for instance, read_attribute, write_attribute, and much of the control logic and
96
+ for instance, +read_attribute+, +write_attribute+, and much of the control logic and
95
97
  parameters.
96
98
 
97
99
  Relations are not yet implemented, but are underway. Relations will use secondary
@@ -1,12 +1,14 @@
1
1
  module OceanDynamo
2
2
  class Base
3
- #include ActiveModel::DeprecatedMassAssignmentSecurity
4
- #include ActiveModel::ForbiddenAttributesProtection
5
3
 
4
+ #
5
+ # The hash of attributes and their values. Keys are strings.
6
+ #
6
7
  attr_reader :attributes
7
- attr_reader :destroyed
8
- attr_reader :new_record
9
- attr_reader :dynamo_item
8
+
9
+ attr_reader :destroyed # :nodoc:
10
+ attr_reader :new_record # :nodoc:
11
+ attr_reader :dynamo_item # :nodoc:
10
12
 
11
13
 
12
14
  def initialize(attrs={})
@@ -1,6 +1,8 @@
1
1
  module OceanDynamo
2
+
2
3
  class Engine < ::Rails::Engine
3
4
  config.generators.integration_tool :rspec
4
5
  config.generators.test_framework :rspec
5
6
  end
7
+
6
8
  end
@@ -183,7 +183,7 @@ module OceanDynamo
183
183
 
184
184
  protected
185
185
 
186
- def self._late_connect?
186
+ def self._late_connect? # :nodoc:
187
187
  return false if table_connected
188
188
  return false unless table_connect_policy
189
189
  establish_db_connection
@@ -191,7 +191,7 @@ module OceanDynamo
191
191
  end
192
192
 
193
193
 
194
- def _late_connect?
194
+ def _late_connect? # :nodoc:
195
195
  self.class._late_connect?
196
196
  end
197
197
 
@@ -215,7 +215,7 @@ module OceanDynamo
215
215
  end
216
216
 
217
217
 
218
- def dynamo_delete(lock: nil)
218
+ def dynamo_delete(lock: nil) # :nodoc:
219
219
  _late_connect?
220
220
  begin
221
221
  options = _handle_locking(lock)
@@ -250,7 +250,7 @@ module OceanDynamo
250
250
  end
251
251
 
252
252
 
253
- def set_timestamps(name=nil)
253
+ def set_timestamps(name=nil) # :nodoc:
254
254
  attrs = []
255
255
  attrs << timestamp_attributes[0] if timestamp_attributes && new_record?
256
256
  attrs << timestamp_attributes[1] if timestamp_attributes
@@ -260,7 +260,7 @@ module OceanDynamo
260
260
  end
261
261
 
262
262
 
263
- def _set_timestamp_attributes(attrs)
263
+ def _set_timestamp_attributes(attrs) # :nodoc:
264
264
  return if attrs.blank?
265
265
  t = Time.zone.now
266
266
  attrs.each { |a| write_attribute a, t }
@@ -268,7 +268,7 @@ module OceanDynamo
268
268
  end
269
269
 
270
270
 
271
- def _handle_locking(lock=lock_attribute)
271
+ def _handle_locking(lock=lock_attribute) # :nodoc:
272
272
  _late_connect?
273
273
  if lock
274
274
  current_v = read_attribute(lock)
@@ -28,7 +28,7 @@ module OceanDynamo
28
28
  self.table_name_suffix = table_name_suffix
29
29
  self.table_read_capacity_units = read_capacity_units
30
30
  self.table_write_capacity_units = write_capacity_units
31
- self.lock_attribute = locking
31
+ self.lock_attribute = locking if locking
32
32
  self.timestamp_attributes = timestamps
33
33
  # Init
34
34
  self.fields = HashWithIndifferentAccess.new
@@ -68,7 +68,7 @@ module OceanDynamo
68
68
 
69
69
  protected
70
70
 
71
- def self.dangerous_attributes
71
+ def self.dangerous_attributes # :nodoc:
72
72
  self.public_methods(false).collect do |sym|
73
73
  str = sym.to_s
74
74
  if str.end_with?("?", "=")
@@ -1,3 +1,3 @@
1
1
  module OceanDynamo
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-dynamo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson
@@ -112,21 +112,19 @@ description: "== OceanDynamo\n\nThis is the OceanDynamo ruby gem, implementing a
112
112
  scalable Amazon DynamoDB near drop-in \nreplacement for ActiveRecord.\n\nAs one
113
113
  important use case for OceanDynamo is to facilitate the conversion of SQL based\nActiveRecord
114
114
  models to DynamoDB based models, it is important that the syntax and semantics\nof
115
- OceanDynamo's operations are as close as possible to those of ActiveRecord. This
116
- means\nthat all callbacks should be available, before, around and after, and that
117
- they should be\ncalled in the same order as in ActiveRecord. Ocean-dynamo follows
118
- this pattern closely and\nis of course based on ActiveModel.\n\nThe attribute and
119
- persistence layer of OceanDynamo is modeled on that of ActiveRecord:\nthere's +save+,
120
- +save!+, +create+, +update+, +update!+, +update_attribute+ and all the other\nmethods
121
- you're used to. The design goal is always to implement as much as possible of the\nActiveRecord
122
- interface, without sacrificing scalability. This makes the task of switching from\nSQL
123
- to no-SQL much easier.\n\nOceanDynamo will use secondary indices to retrieve related
124
- table items, \nwhich means it will scale without limits. (NB: this is a pre-release
125
- which as yet doesn't\nimplement relations, but they are underway.)\n\nDue to its
126
- similarity to ActiveRecord, OceanDynamo works with FactoryGirl.\nFurthermore, future
127
- versions will keep track of and delete instances after tests.\n\nSee also Ocean,
128
- a Rails framework for creating highly scalable SOAs in the cloud, in which\nocean-dynamo
129
- is used as a central component: http://wiki.oceanframework.net"
115
+ OceanDynamo's operations are as close as possible to those of ActiveRecord, including\ncallbacks,
116
+ exceptions and support methods. Ocean-dynamo follows this pattern closely and\nis
117
+ of course based on ActiveModel.\n\nThe attribute and persistence layer of OceanDynamo
118
+ is modeled on that of ActiveRecord:\nthere's +save+, +save!+, +create+, +update+,
119
+ +update!+, +update_attributes+ and all the other\nmethods you're used to. The design
120
+ goal is always to implement as much as possible of the\nActiveRecord interface,
121
+ without sacrificing scalability. This makes the task of switching from\nSQL to no-SQL
122
+ much easier.\n\nOceanDynamo will use secondary indices to retrieve related table
123
+ items, \nwhich means OceanDynamo tables will scale without limits.\n\nThanks to
124
+ its structural similarity to ActiveRecord, OceanDynamo works with FactoryGirl.\nTo
125
+ facilitate testing, future versions will keep track of and delete instances after
126
+ tests.\n\nSee also Ocean, a Rails framework for creating highly scalable SOAs in
127
+ the cloud, in which\nocean-dynamo is used as a central component: http://wiki.oceanframework.net"
130
128
  email:
131
129
  - peter@peterbengtson.com
132
130
  executables: []