lib/cuba_api/utils.rb in cuba-api-0.3.2 vs lib/cuba_api/utils.rb in cuba-api-0.3.3
- old
+ new
@@ -17,18 +17,27 @@
else
default
end
end
+ def to_boolean( name, default = nil )
+ v = req[ name ]
+ if v
+ v == 'true'
+ else
+ default
+ end
+ end
+
def offset_n_limit( method, set )
count = set.count
offset = to_int( 'offset' ).to_i
limit = ( to_int( 'count' ) || count ) - 1 + offset
{ method => set[ offset..limit ], :offset => offset, :total_count => count }
end
def last_modified( last )
- res[ 'Last-Modified' ] = rfc2616( last )
+ res[ 'Last-Modified' ] = rfc2616( last ) if last
end
def modified_since
@modified_since ||=
if date = env[ 'HTTP_IF_MODIFIED_SINCE' ]