Sha256: 3bbb1ad3f2fe346210815ff264ce74e2d996916ecf8f04b15202056c688951f7
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
module DataMapper module CubaPlugin # matcher def no_path Proc.new { env[ 'PATH_INFO' ].empty? } end # matcher def head req.head? end def option req.options? end # convenient method for status only responses def no_body( status ) res.status = ::Rack::Utils.status_code( status ) res.write ::Rack::Utils::HTTP_STATUS_CODES[ res.status ] res['Content-Type' ] = 'text/plain' end # params def to_float( name, default = nil ) v = req[ name ] if v v.to_f else default end end def to_int( name, default = nil ) v = req[ name ] if v v.to_i 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 ) if last res[ 'Last-Modified' ] = rfc2616( last ) res[ 'Cache-Control' ] = "private, max-age=0, must-revalidate" end end def modified_since @modified_since ||= if date = env[ 'HTTP_IF_MODIFIED_SINCE' ] DateTime.parse( date ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ixtlan-datamapper-0.1.0 | lib/ixtlan/datamapper/cuba_plugin.rb~ |