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

require 'sanford/route'

module Sanford

  class Router

    attr_reader :routes

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

    def service_handler_ns(value = nil)
      @service_handler_ns = value if !value.nil?
      @service_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

Stop defaulting `@service_handler_ns` to `nil` in `Router`
Hotfix: Stop defaulting `@service_handler_ns` to `nil` in `Router`

This changes `Router` to no longer manually set its
`@service_handler_ns` to `nil`. This caused problems with
inheriting from the `Router` class and trying to default the
service handler ns. Since all ivars are defaulted to `nil` this
isn't required so this removes it to avoid the issues.

This also fixes a bug where the service handler ns method was
setting a view handler ns ivar instead of a service handler ns
ivar.

/cc @kellyredding
