Sha256: a7dda08619f008c1131a2147d3645e9e30f33bb1a0c51c2daed04e7b6843eedf

Contents?: true

Size: 653 Bytes

Versions: 54

Compression:

Stored size: 653 Bytes

Contents

module Dugway
  class Request < Rack::Request
    def params
      super.update(env['rack.routing_args']).symbolize_keys
    end
    
    def page_permalink
      case path
      when %r{^/$}
        'home'
      when %r{^/(products|category|artist)/}
        'products'
      when %r{^/product/}
        'product'
      else
        File.basename(path[1..-1], '.*')
      end
    end
    
    def extension
      File.extname(path).present? ? File.extname(path) : '.html'
    end
    
    def format
      params[:format] || extension[1..-1]
    end
    
    def html?
      format == 'html'
    end

    def js?
      format == 'js'
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
dugway-0.6.4 lib/dugway/request.rb
dugway-0.6.3 lib/dugway/request.rb
dugway-0.6.2 lib/dugway/request.rb
dugway-0.6.1 lib/dugway/request.rb
dugway-0.6.0 lib/dugway/request.rb
dugway-0.5.9 lib/dugway/request.rb
dugway-0.5.8 lib/dugway/request.rb
dugway-0.5.7 lib/dugway/request.rb
dugway-0.5.6 lib/dugway/request.rb
dugway-0.5.4 lib/dugway/request.rb
dugway-0.5.3 lib/dugway/request.rb
dugway-0.5.2 lib/dugway/request.rb
dugway-0.5.1 lib/dugway/request.rb
dugway-0.5.0 lib/dugway/request.rb