Sha256: 9bf381c42d4df0f99702dc73f0ffad57a215f0a6a64873ea796c2367ec9728b0

Contents?: true

Size: 772 Bytes

Versions: 4

Compression:

Stored size: 772 Bytes

Contents

require 'sanford/route'

module Sanford

  class Router

    attr_reader :routes

    def initialize(&block)
      @service_handler_ns = nil
      @routes = []
      self.instance_eval(&block) if !block.nil?
    end

    def service_handler_ns(value = nil)
      @view_handler_ns = value if !value.nil?
      @view_handler_ns
    end

    def service(name, handler_name)
      if self.service_handler_ns && !(handler_name =~ /^::/)
        handler_name = "#{self.service_handler_ns}::#{handler_name}"
      end

      @routes.push(Sanford::Route.new(name, handler_name))
    end

    def inspect
      reference = '0x0%x' % (self.object_id << 1)
      "#<#{self.class}:#{reference} " \
        "@service_handler_ns=#{self.service_handler_ns.inspect}>"
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sanford-0.13.0 lib/sanford/router.rb
sanford-0.12.0 lib/sanford/router.rb
sanford-0.11.1 lib/sanford/router.rb
sanford-0.11.0 lib/sanford/router.rb