Sha256: c8023d10143f7a71462e18fd1a4176f46bc5a1ecec184255e34d150e9cf46738

Contents?: true

Size: 847 Bytes

Versions: 26

Compression:

Stored size: 847 Bytes

Contents

# -*- encoding : utf-8 -*-
module BentoSearch
  class Routes

    def initialize(router, options = {})
      @router = router
      @options = {:scope => "/bento"}.merge(options)
    end

    def draw
      route_sets.each do |r|
        self.send(r)
      end
    end

    protected

    def add_routes &blk
      @router.instance_exec(@options, &blk)
    end

    def route_sets
      (@options[:only] || default_route_sets) - (@options[:except] || [])
    end

    def default_route_sets
      # :search should always be LAST
      [:search]
    end

    module RouteSets
      
      def search
        add_routes do |options|
          scope options[:scope] do
            get ":engine_id" => "bento_search/search#search", :as => "to_bento_search"
          end
        end
        
      end
        
    end
    include RouteSets
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
bento_search-2.0.0.rc1 lib/bento_search/routes.rb
bento_search-1.7.0 lib/bento_search/routes.rb
bento_search-1.6.1 lib/bento_search/routes.rb
bento_search-1.7.0.beta.1 lib/bento_search/routes.rb
bento_search-1.6.0 lib/bento_search/routes.rb
bento_search-1.5.0 lib/bento_search/routes.rb
bento_search-1.4.4 lib/bento_search/routes.rb
bento_search-1.4.3 lib/bento_search/routes.rb
bento_search-1.4.2 lib/bento_search/routes.rb
bento_search-1.3.0 lib/bento_search/routes.rb
bento_search-1.2.2 lib/bento_search/routes.rb
bento_search-1.2.1 lib/bento_search/routes.rb
bento_search-1.2.0 lib/bento_search/routes.rb
bento_search-1.1.0 lib/bento_search/routes.rb
bento_search-1.0.6 lib/bento_search/routes.rb
bento_search-1.0.4 lib/bento_search/routes.rb
bento_search-1.0.3 lib/bento_search/routes.rb
bento_search-1.0.2 lib/bento_search/routes.rb
bento_search-1.0.1 lib/bento_search/routes.rb
bento_search-1.0.0 lib/bento_search/routes.rb