Sha256: 4e6af0fa30839176fa64993f855e37aacd224adf25fe9a82619edf325466e411

Contents?: true

Size: 715 Bytes

Versions: 4

Compression:

Stored size: 715 Bytes

Contents

require 'deas/exceptions'
require 'deas/view_handler'

module Deas
  class RouteProxy

    attr_reader :handler_class_name, :handler_class

    def initialize(handler_class_name)
      @handler_class_name = handler_class_name
    end

    def validate!
      @handler_class = constantize(@handler_class_name).tap do |handler_class|
        raise(NoHandlerClassError.new(@handler_class_name)) if !handler_class
      end
    end

    private

    def constantize(class_name)
      names = class_name.to_s.split('::').reject{ |name| name.empty? }
      klass = names.inject(Object){ |constant, name| constant.const_get(name) }
      klass == Object ? false : klass
    rescue NameError
      false
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
deas-0.31.0 lib/deas/route_proxy.rb
deas-0.30.0 lib/deas/route_proxy.rb
deas-0.29.0 lib/deas/route_proxy.rb
deas-0.28.0 lib/deas/route_proxy.rb