Sha256: 76fbdd140b85b4da70f5f9b38c7b51253cbd67a590975156b179d6587c9b89c9

Contents?: true

Size: 1.4 KB

Versions: 21

Compression:

Stored size: 1.4 KB

Contents

$:.unshift File.dirname(__FILE__)

require 'merb-core'
require 'merb-core/dispatch/router/behavior'

class Usher
  module Interface
    class MerbInterface
      
      # merb does everything with class methods.

      @root_behavior   = ::Merb::Router::Behavior.new.defaults(:action => "index")

      class << self
        attr_accessor :root_behavior
        
        UsherRoutes = Usher.new
        
        def prepare(first = [], last = [], &block)
          @routes = []
          root_behavior._with_proxy(&block)
          @routes = first + @routes + last
          compile
          self
        end
        
        def compile
          routes.each do |r| 
            r.segments
          end
          
          #puts r.inspect; UsherRoutes.add_route(r) }
          #routes.each {|r| }
        end
        
        def named_routes
          UsherRoutes.named_routes
        end
        
        def routes
          UsherRoutes.routes
        end

        def route_for(request)
          p request
          p UsherRoutes.tree
          UsherRoutes.recognize(request)
        end
        
      end
      
      #class BootLoader < ::Merb::BootLoader
      #end

      def load_into_merb!
        ::Merb.send(:remove_const, "Router")
        ::Merb.const_set("Router", Usher::Interface::MerbInterface)
        #::Merb::BootLoader.const_set("Router", Usher::Interface::Merb::BootLoader)
      end
      
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
joshbuddy-usher-0.0.2 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.0.3 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.1.0 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.1.1 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.1.2 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.2.0 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.2.1 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.2.2 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.3.0 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.3.2 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.3.3 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.3.4 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.3.5 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.3.6 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.4.0 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.4.1 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.4.2 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.4.3 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.4.5 lib/usher/interface/merb_interface.rb
joshbuddy-usher-0.4.6 lib/usher/interface/merb_interface.rb