aws-sdk 1.2.6 → 1.3.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.
- data/lib/aws.rb +2 -0
- data/lib/aws/api_config/DynamoDB-2011-12-05.yml +721 -0
- data/lib/aws/core.rb +10 -1
- data/lib/aws/core/client.rb +17 -12
- data/lib/aws/core/configuration.rb +13 -3
- data/lib/aws/core/configured_json_client_methods.rb +71 -0
- data/lib/aws/core/lazy_error_classes.rb +7 -2
- data/lib/aws/core/option_grammar.rb +67 -13
- data/lib/aws/core/resource.rb +9 -1
- data/lib/aws/core/session_signer.rb +95 -0
- data/lib/aws/dynamo_db.rb +169 -0
- data/lib/aws/dynamo_db/attribute_collection.rb +460 -0
- data/lib/aws/dynamo_db/batch_get.rb +206 -0
- data/lib/aws/dynamo_db/client.rb +119 -0
- data/lib/aws/dynamo_db/config.rb +20 -0
- data/lib/aws/dynamo_db/errors.rb +57 -0
- data/lib/aws/dynamo_db/expectations.rb +40 -0
- data/lib/aws/dynamo_db/item.rb +130 -0
- data/lib/aws/dynamo_db/item_collection.rb +837 -0
- data/lib/aws/{record/optimistic_locking.rb → dynamo_db/item_data.rb} +9 -12
- data/lib/aws/{record/attributes/boolean.rb → dynamo_db/keys.rb} +15 -23
- data/lib/aws/dynamo_db/primary_key_element.rb +47 -0
- data/lib/aws/dynamo_db/request.rb +78 -0
- data/lib/aws/{record/attributes/float.rb → dynamo_db/resource.rb} +10 -25
- data/lib/aws/dynamo_db/table.rb +418 -0
- data/lib/aws/dynamo_db/table_collection.rb +165 -0
- data/lib/aws/dynamo_db/types.rb +86 -0
- data/lib/aws/ec2/resource_tag_collection.rb +3 -1
- data/lib/aws/record.rb +36 -8
- data/lib/aws/record/abstract_base.rb +642 -0
- data/lib/aws/record/attributes.rb +384 -0
- data/lib/aws/record/dirty_tracking.rb +0 -1
- data/lib/aws/record/errors.rb +0 -8
- data/lib/aws/record/hash_model.rb +163 -0
- data/lib/aws/record/hash_model/attributes.rb +182 -0
- data/lib/aws/record/hash_model/finder_methods.rb +178 -0
- data/lib/aws/record/hash_model/scope.rb +108 -0
- data/lib/aws/record/model.rb +429 -0
- data/lib/aws/record/model/attributes.rb +377 -0
- data/lib/aws/record/model/finder_methods.rb +232 -0
- data/lib/aws/record/model/scope.rb +213 -0
- data/lib/aws/record/scope.rb +43 -169
- data/lib/aws/record/validations.rb +11 -11
- data/lib/aws/s3/client.rb +9 -6
- data/lib/aws/s3/object_collection.rb +1 -1
- data/lib/aws/simple_db/expect_condition_option.rb +1 -1
- data/lib/aws/simple_db/item_collection.rb +5 -3
- data/lib/aws/sts/client.rb +9 -0
- metadata +73 -30
- data/lib/aws/record/attribute.rb +0 -94
- data/lib/aws/record/attribute_macros.rb +0 -312
- data/lib/aws/record/attributes/date.rb +0 -89
- data/lib/aws/record/attributes/datetime.rb +0 -86
- data/lib/aws/record/attributes/integer.rb +0 -68
- data/lib/aws/record/attributes/sortable_float.rb +0 -60
- data/lib/aws/record/attributes/sortable_integer.rb +0 -95
- data/lib/aws/record/attributes/string.rb +0 -69
- data/lib/aws/record/base.rb +0 -828
- data/lib/aws/record/finder_methods.rb +0 -230
- data/lib/aws/record/scopes.rb +0 -55
@@ -1,312 +0,0 @@
|
|
1
|
-
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
-
# may not use this file except in compliance with the License. A copy of
|
5
|
-
# the License is located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is
|
10
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
-
# ANY KIND, either express or implied. See the License for the specific
|
12
|
-
# language governing permissions and limitations under the License.
|
13
|
-
|
14
|
-
require 'aws/record/attributes/string'
|
15
|
-
require 'aws/record/attributes/integer'
|
16
|
-
require 'aws/record/attributes/sortable_integer'
|
17
|
-
require 'aws/record/attributes/float'
|
18
|
-
require 'aws/record/attributes/sortable_float'
|
19
|
-
require 'aws/record/attributes/boolean'
|
20
|
-
require 'aws/record/attributes/datetime'
|
21
|
-
require 'aws/record/attributes/date'
|
22
|
-
|
23
|
-
module AWS
|
24
|
-
module Record
|
25
|
-
module AttributeMacros
|
26
|
-
|
27
|
-
# Adds a string attribute to this class.
|
28
|
-
#
|
29
|
-
# @example A standard string attribute
|
30
|
-
#
|
31
|
-
# class Recipe < AWS::Record::Base
|
32
|
-
# string_attr :name
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# recipe = Recipe.new(:name => "Buttermilk Pancakes")
|
36
|
-
# recipe.name #=> 'Buttermilk Pancakes'
|
37
|
-
#
|
38
|
-
# @example A string attribute with +:set+ set to true
|
39
|
-
#
|
40
|
-
# class Recipe < AWS::Record::Base
|
41
|
-
# string_attr :tags, :set => true
|
42
|
-
# end
|
43
|
-
#
|
44
|
-
# recipe = Recipe.new(:tags => %w(popular dessert))
|
45
|
-
# recipe.tags #=> #<Set: {"popular", "desert"}>
|
46
|
-
#
|
47
|
-
# @param [Symbol] name The name of the attribute.
|
48
|
-
# @param [Hash] options
|
49
|
-
# @option options [Boolean] :set (false) When true this attribute
|
50
|
-
# can have multiple values.
|
51
|
-
def string_attr name, options = {}
|
52
|
-
add_attribute(StringAttribute.new(name, options))
|
53
|
-
end
|
54
|
-
|
55
|
-
# Adds an integer attribute to this class.
|
56
|
-
#
|
57
|
-
# class Recipe < AWS::Record::Base
|
58
|
-
# integer_attr :servings
|
59
|
-
# end
|
60
|
-
#
|
61
|
-
# recipe = Recipe.new(:servings => '10')
|
62
|
-
# recipe.servings #=> 10
|
63
|
-
#
|
64
|
-
# @param [Symbol] name The name of the attribute.
|
65
|
-
# @param [Hash] options
|
66
|
-
# @option options [Boolean] :set (false) When true this attribute
|
67
|
-
# can have multiple values.
|
68
|
-
def integer_attr name, options = {}
|
69
|
-
add_attribute(IntegerAttribute.new(name, options))
|
70
|
-
end
|
71
|
-
|
72
|
-
# Adds a sortable integer attribute to this class.
|
73
|
-
#
|
74
|
-
# class Person < AWS::Record::Base
|
75
|
-
# sortable_integer_attr :age, :range => 0..150
|
76
|
-
# end
|
77
|
-
#
|
78
|
-
# person = Person.new(:age => 10)
|
79
|
-
# person.age #=> 10
|
80
|
-
#
|
81
|
-
# === Validations
|
82
|
-
#
|
83
|
-
# It is recomended to apply a validates_numericality_of with
|
84
|
-
# minimum and maximum value constraints. If a value is assigned
|
85
|
-
# to a sortable integer that falls outside of the +:range: it will
|
86
|
-
# raise a runtime error when the record is saved.
|
87
|
-
#
|
88
|
-
# === Difference Between Sortable an Regular Integer Attributes
|
89
|
-
#
|
90
|
-
# Because SimpleDB does not support numeric types, all values must
|
91
|
-
# be converted to strings. This complicates sorting by numeric values.
|
92
|
-
# To accomplish sorting numeric attributes the values must be
|
93
|
-
# zero padded and have an offset applied to eliminate negative values.
|
94
|
-
#
|
95
|
-
# @param [Symbol] name The name of the attribute.
|
96
|
-
# @param [Hash] options
|
97
|
-
# @option options [Range] :range A numeric range the represents the
|
98
|
-
# minimum and maximum values this attribute should accept.
|
99
|
-
# @option options [Boolean] :set (false) When true this attribute
|
100
|
-
# can have multiple values.
|
101
|
-
def sortable_integer_attr name, options = {}
|
102
|
-
add_attribute(SortableIntegerAttribute.new(name, options))
|
103
|
-
end
|
104
|
-
|
105
|
-
# Adds a float attribute to this class.
|
106
|
-
#
|
107
|
-
# class Listing < AWS::Record::Base
|
108
|
-
# float_attr :score
|
109
|
-
# end
|
110
|
-
#
|
111
|
-
# listing = Listing.new(:score => '123.456')
|
112
|
-
# listing.score # => 123.456
|
113
|
-
#
|
114
|
-
# @param [Symbol] name The name of the attribute.
|
115
|
-
# @param [Hash] options
|
116
|
-
# @option options [Boolean] :set (false) When true this attribute
|
117
|
-
# can have multiple values.
|
118
|
-
def float_attr name, options = {}
|
119
|
-
add_attribute(FloatAttribute.new(name, options))
|
120
|
-
end
|
121
|
-
|
122
|
-
# Adds sortable float attribute to this class.
|
123
|
-
#
|
124
|
-
# Persisted values are stored (and sorted) as strings. This makes it
|
125
|
-
# more difficult to sort numbers because they don't sort
|
126
|
-
# lexicographically unless they have been offset to be positive and
|
127
|
-
# then zero padded.
|
128
|
-
#
|
129
|
-
# === Postive Floats
|
130
|
-
#
|
131
|
-
# To store floats in a sort-friendly manor:
|
132
|
-
#
|
133
|
-
# sortable_float_attr :score, :range => (0..10)
|
134
|
-
#
|
135
|
-
# This will cause values like 5.5 to persist as a string like '05.5' so
|
136
|
-
# that they can be sorted lexicographically.
|
137
|
-
#
|
138
|
-
# === Negative Floats
|
139
|
-
#
|
140
|
-
# If you need to store negative sortable floats, increase your +:range+
|
141
|
-
# to include a negative value.
|
142
|
-
#
|
143
|
-
# sortable_float_attr :position, :range => (-10..10)
|
144
|
-
#
|
145
|
-
# AWS::Record will add 10 to all values and zero pad them
|
146
|
-
# (e.g. -10.0 will be represented as '00.0' and 10 will be represented as
|
147
|
-
# '20.0'). This will allow the values to be compared lexicographically.
|
148
|
-
#
|
149
|
-
# @note If you change the +:range+ after some values have been persisted
|
150
|
-
# you must also manually migrate all of the old values to have the
|
151
|
-
# correct padding & offset or they will be interpreted differently.
|
152
|
-
#
|
153
|
-
# @param [Symbol] name The name of the attribute.
|
154
|
-
# @param [Hash] options
|
155
|
-
# @option options [Range] :range The range of numbers this attribute
|
156
|
-
# should represent. The min and max values of this range will determine
|
157
|
-
# how many digits of precision are required and how much of an offset
|
158
|
-
# is required to make the numbers sort lexicographically.
|
159
|
-
# @option options [Boolean] :set (false) When true this attribute
|
160
|
-
# can have multiple values.
|
161
|
-
def sortable_float_attr name, options = {}
|
162
|
-
add_attribute(SortableFloatAttribute.new(name, options))
|
163
|
-
end
|
164
|
-
|
165
|
-
# Adds a boolean attribute to this class.
|
166
|
-
#
|
167
|
-
# @example
|
168
|
-
#
|
169
|
-
# class Book < AWS::Record::Base
|
170
|
-
# boolean_attr :read
|
171
|
-
# end
|
172
|
-
#
|
173
|
-
# b = Book.new
|
174
|
-
# b.read? # => false
|
175
|
-
# b.read = true
|
176
|
-
# b.read? # => true
|
177
|
-
#
|
178
|
-
# listing = Listing.new(:score => '123.456'
|
179
|
-
# listing.score # => 123.456
|
180
|
-
#
|
181
|
-
# @param [Symbol] name The name of the attribute.
|
182
|
-
def boolean_attr name, options = {}
|
183
|
-
|
184
|
-
attr = add_attribute(BooleanAttribute.new(name, options))
|
185
|
-
|
186
|
-
# add the boolean question mark method
|
187
|
-
define_method("#{attr.name}?") do
|
188
|
-
!!__send__(attr.name)
|
189
|
-
end
|
190
|
-
|
191
|
-
end
|
192
|
-
|
193
|
-
# Adds a datetime attribute to this class.
|
194
|
-
#
|
195
|
-
# @example A standard datetime attribute
|
196
|
-
#
|
197
|
-
# class Recipe < AWS::Record::Base
|
198
|
-
# datetime_attr :invented
|
199
|
-
# end
|
200
|
-
#
|
201
|
-
# recipe = Recipe.new(:invented => Time.now)
|
202
|
-
# recipe.invented #=> <DateTime ...>
|
203
|
-
#
|
204
|
-
# If you add a datetime_attr for +:created_at+ and/or +:updated_at+ those
|
205
|
-
# will be automanaged.
|
206
|
-
#
|
207
|
-
# @param [Symbol] name The name of the attribute.
|
208
|
-
#
|
209
|
-
# @param [Hash] options
|
210
|
-
#
|
211
|
-
# @option options [Boolean] :set (false) When true this attribute
|
212
|
-
# can have multiple date times.
|
213
|
-
#
|
214
|
-
def datetime_attr name, options = {}
|
215
|
-
add_attribute(DateTimeAttribute.new(name, options))
|
216
|
-
end
|
217
|
-
|
218
|
-
# Adds a date attribute to this class.
|
219
|
-
#
|
220
|
-
# @example A standard date attribute
|
221
|
-
#
|
222
|
-
# class Person < AWS::Record::Base
|
223
|
-
# date_attr :birthdate
|
224
|
-
# end
|
225
|
-
#
|
226
|
-
# baby = Person.new
|
227
|
-
# baby.birthdate = Time.now
|
228
|
-
# baby.birthdate #=> <Date: ....>
|
229
|
-
#
|
230
|
-
# @param [Symbol] name The name of the attribute.
|
231
|
-
#
|
232
|
-
# @param [Hash] options
|
233
|
-
#
|
234
|
-
# @option options [Boolean] :set (false) When true this attribute
|
235
|
-
# can have multiple dates.
|
236
|
-
#
|
237
|
-
def date_attr name, options = {}
|
238
|
-
add_attribute(DateAttribute.new(name, options))
|
239
|
-
end
|
240
|
-
|
241
|
-
# A convenience method for adding the standard two datetime attributes
|
242
|
-
# +:created_at+ and +:updated_at+.
|
243
|
-
#
|
244
|
-
# @example
|
245
|
-
#
|
246
|
-
# class Recipe < AWS::Record::Base
|
247
|
-
# timestamps
|
248
|
-
# end
|
249
|
-
#
|
250
|
-
# recipe = Recipe.new
|
251
|
-
# recipe.save
|
252
|
-
# recipe.created_at #=> <DateTime ...>
|
253
|
-
# recipe.updated_at #=> <DateTime ...>
|
254
|
-
#
|
255
|
-
def timestamps
|
256
|
-
c = datetime_attr :created_at
|
257
|
-
u = datetime_attr :updated_at
|
258
|
-
[c, u]
|
259
|
-
end
|
260
|
-
|
261
|
-
# @private
|
262
|
-
private
|
263
|
-
def add_attribute attribute
|
264
|
-
|
265
|
-
attr_name = attribute.name
|
266
|
-
|
267
|
-
attributes[attr_name] = attribute
|
268
|
-
|
269
|
-
# setter
|
270
|
-
define_method("#{attr_name}=") do |value|
|
271
|
-
self[attr_name] = value
|
272
|
-
end
|
273
|
-
|
274
|
-
# getter
|
275
|
-
define_method(attr_name) do
|
276
|
-
self[attr_name]
|
277
|
-
end
|
278
|
-
|
279
|
-
# before type-cast getter
|
280
|
-
define_method("#{attr_name}_before_type_cast") do
|
281
|
-
@_data[attr_name]
|
282
|
-
end
|
283
|
-
|
284
|
-
## dirty tracking methods
|
285
|
-
|
286
|
-
define_method("#{attr_name}_changed?") do
|
287
|
-
attribute_changed?(attr_name)
|
288
|
-
end
|
289
|
-
|
290
|
-
define_method("#{attr_name}_change") do
|
291
|
-
attribute_change(attr_name)
|
292
|
-
end
|
293
|
-
|
294
|
-
define_method("#{attr_name}_was") do
|
295
|
-
attribute_was(attr_name)
|
296
|
-
end
|
297
|
-
|
298
|
-
define_method("#{attr_name}_will_change!") do
|
299
|
-
attribute_will_change!(attr_name)
|
300
|
-
end
|
301
|
-
|
302
|
-
define_method("reset_#{attr_name}!") do
|
303
|
-
reset_attribute!(attr_name)
|
304
|
-
end
|
305
|
-
|
306
|
-
attribute
|
307
|
-
|
308
|
-
end
|
309
|
-
|
310
|
-
end
|
311
|
-
end
|
312
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
-
# may not use this file except in compliance with the License. A copy of
|
5
|
-
# the License is located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is
|
10
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
-
# ANY KIND, either express or implied. See the License for the specific
|
12
|
-
# language governing permissions and limitations under the License.
|
13
|
-
|
14
|
-
require 'date'
|
15
|
-
require 'aws/record/attribute'
|
16
|
-
|
17
|
-
module AWS
|
18
|
-
module Record
|
19
|
-
|
20
|
-
# @private
|
21
|
-
class DateAttribute < Attribute
|
22
|
-
|
23
|
-
# Returns value cast to a Date object. Empty strings are cast to
|
24
|
-
# nil. Values are cast first to strings and then passed to
|
25
|
-
# Date.parse. Integers are treated as timestamps.
|
26
|
-
#
|
27
|
-
# date_attribute.type_cast('2000-01-02T10:11:12Z')
|
28
|
-
# #=> #<Date: 4903091/2,0,2299161>
|
29
|
-
#
|
30
|
-
# date_attribute.type_cast(1306170146)
|
31
|
-
# #<Date: 4911409/2,0,2299161>
|
32
|
-
#
|
33
|
-
# date_attribute.type_cast('')
|
34
|
-
# #=> nil
|
35
|
-
#
|
36
|
-
# date_attribute.type_cast(nil)
|
37
|
-
# #=> nil
|
38
|
-
#
|
39
|
-
# @param [Mixed] raw_value The value to cast to a Date object.
|
40
|
-
# @param [Hash] options
|
41
|
-
# @return [Date,nil]
|
42
|
-
def self.type_cast raw_value, options = {}
|
43
|
-
case raw_value
|
44
|
-
when nil then nil
|
45
|
-
when '' then nil
|
46
|
-
when Date then raw_value
|
47
|
-
when Integer then
|
48
|
-
begin
|
49
|
-
Date.parse(Time.at(raw_value).to_s) # assumed timestamp
|
50
|
-
rescue
|
51
|
-
nil
|
52
|
-
end
|
53
|
-
else
|
54
|
-
begin
|
55
|
-
Date.parse(raw_value.to_s) # Time, DateTime or String
|
56
|
-
rescue
|
57
|
-
nil
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Returns a Date object encoded as a string (suitable for sorting).
|
63
|
-
#
|
64
|
-
# attribute.serialize(DateTime.parse('2001-01-01'))
|
65
|
-
# #=> '2001-01-01'
|
66
|
-
#
|
67
|
-
# @param [Date] datetime The date to serialize.
|
68
|
-
#
|
69
|
-
# @param [Hash] options
|
70
|
-
#
|
71
|
-
# @return [String] Returns the date object serialized to a string
|
72
|
-
# ('YYYY-MM-DD').
|
73
|
-
#
|
74
|
-
def self.serialize date, options = {}
|
75
|
-
unless date.is_a?(Date)
|
76
|
-
raise ArgumentError, "expected a Date value, got #{date.class}"
|
77
|
-
end
|
78
|
-
date.strftime('%Y-%m-%d')
|
79
|
-
end
|
80
|
-
|
81
|
-
# @private
|
82
|
-
def self.allow_set?
|
83
|
-
true
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
-
# may not use this file except in compliance with the License. A copy of
|
5
|
-
# the License is located at
|
6
|
-
#
|
7
|
-
# http://aws.amazon.com/apache2.0/
|
8
|
-
#
|
9
|
-
# or in the "license" file accompanying this file. This file is
|
10
|
-
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
-
# ANY KIND, either express or implied. See the License for the specific
|
12
|
-
# language governing permissions and limitations under the License.
|
13
|
-
|
14
|
-
require 'aws/record/attribute'
|
15
|
-
|
16
|
-
module AWS
|
17
|
-
module Record
|
18
|
-
|
19
|
-
# @private
|
20
|
-
class DateTimeAttribute < Attribute
|
21
|
-
|
22
|
-
# Returns value cast to a DateTime object. Empty strings are cast to
|
23
|
-
# nil. Values are cast first to strings and then passed to
|
24
|
-
# DateTime.parse. Integers are treated as timestamps.
|
25
|
-
#
|
26
|
-
# datetime_attribute.type_cast('2000-01-02')
|
27
|
-
# #=> #<DateTime: 4903091/2,0,2299161>
|
28
|
-
#
|
29
|
-
# datetime_attribute.type_cast(1306170146)
|
30
|
-
# #<DateTime: 106086465073/43200,-7/24,2299161>
|
31
|
-
#
|
32
|
-
# datetime_attribute.type_cast('')
|
33
|
-
# #=> nil
|
34
|
-
#
|
35
|
-
# datetime_attribute.type_cast(nil)
|
36
|
-
# #=> nil
|
37
|
-
#
|
38
|
-
# @param [Mixed] raw_value The value to cast to a DateTime object.
|
39
|
-
# @param [Hash] options
|
40
|
-
# @return [DateTime,nil]
|
41
|
-
def self.type_cast raw_value, options = {}
|
42
|
-
case raw_value
|
43
|
-
when nil then nil
|
44
|
-
when '' then nil
|
45
|
-
when DateTime then raw_value
|
46
|
-
when Integer then
|
47
|
-
begin
|
48
|
-
DateTime.parse(Time.at(raw_value).to_s) # timestamp
|
49
|
-
rescue
|
50
|
-
nil
|
51
|
-
end
|
52
|
-
else
|
53
|
-
begin
|
54
|
-
DateTime.parse(raw_value.to_s) # Time, Date or String
|
55
|
-
rescue
|
56
|
-
nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# Returns a DateTime object encoded as a string (suitable for sorting).
|
62
|
-
#
|
63
|
-
# attribute.serialize(DateTime.parse('2001-01-01'))
|
64
|
-
# #=> '2001-01-01T00:00:00:Z)
|
65
|
-
#
|
66
|
-
# @param [DateTime] datetime The datetime object to serialize.
|
67
|
-
# @param [Hash] options
|
68
|
-
# @return [String] Returns the datetime object serialized to a string
|
69
|
-
# in ISO8601 format (e.g. '2011-01-02T10:11:12Z')
|
70
|
-
def self.serialize datetime, options = {}
|
71
|
-
unless datetime.is_a?(DateTime)
|
72
|
-
msg = "expected a DateTime value, got #{datetime.class}"
|
73
|
-
raise ArgumentError, msg
|
74
|
-
end
|
75
|
-
datetime.strftime('%Y-%m-%dT%H:%M:%S%Z')
|
76
|
-
end
|
77
|
-
|
78
|
-
# @private
|
79
|
-
def self.allow_set?
|
80
|
-
true
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|