sinatra_resource 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/builder/helpers.rb +13 -1
- data/lib/builder/mongo_helpers.rb +0 -10
- data/sinatra_resource.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/lib/builder/helpers.rb
CHANGED
@@ -415,7 +415,19 @@ module SinatraResource
|
|
415
415
|
if proc
|
416
416
|
proc.call(document)
|
417
417
|
else
|
418
|
-
document
|
418
|
+
document[attribute == :id ? :_id : attribute]
|
419
|
+
# An alternate way is:
|
420
|
+
#
|
421
|
+
# document.send(attribute == :id ? :_id : attribute)
|
422
|
+
#
|
423
|
+
# This will work; however, it would be confusing to support
|
424
|
+
# properties backed by model methods here if we don't do it
|
425
|
+
# everywhere. And supporting it everywhere would be tricky.
|
426
|
+
#
|
427
|
+
# For example, the filtering code relies on using MongoDB to
|
428
|
+
# search the database. If we supported properties backed by model
|
429
|
+
# methods, filtering / searching would be more complicated and
|
430
|
+
# expensive.
|
419
431
|
end
|
420
432
|
end
|
421
433
|
|
@@ -410,16 +410,6 @@ module SinatraResource
|
|
410
410
|
# Can it be done more quickly?
|
411
411
|
end
|
412
412
|
|
413
|
-
# Returns a typecasted +value+. (Uses +model+ and +key_string+ to
|
414
|
-
# figure out how to typecast it.)
|
415
|
-
#
|
416
|
-
# @return [Object]
|
417
|
-
def typecast(model, key_string, value)
|
418
|
-
dummy = model.new
|
419
|
-
dummy.send(:"#{key_string}=", value)
|
420
|
-
dummy.send(:"#{key_string}")
|
421
|
-
end
|
422
|
-
|
423
413
|
end
|
424
414
|
|
425
415
|
end
|
data/sinatra_resource.gemspec
CHANGED