Skip to content

Commit

Permalink
Use Utils::Class loading mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Aug 8, 2013
1 parent 4c2e3f9 commit ee8108b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/lotus/routing/endpoint.rb
@@ -1,3 +1,5 @@
require 'lotus/utils/class'

module Lotus
module Routing
class Endpoint < SimpleDelegator
Expand All @@ -20,7 +22,7 @@ def call(env)

private
def obj
@namespace.const_get(@name).new
Utils::Class.load!(@name, @namespace).new
end
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/lotus/routing/endpoint_resolver.rb
@@ -1,10 +1,11 @@
require 'lotus/utils/string'
require 'lotus/utils/class'
require 'lotus/routing/endpoint'

module Lotus
module Routing
class EndpointResolver
SUFFIX = 'Controller::'.freeze
SUFFIX = '(::Controller::|Controller::)'.freeze

def initialize(options = {})
@namespace = options[:namespace] || Object
Expand Down Expand Up @@ -46,7 +47,7 @@ def default

def constantize(string)
begin
ClassEndpoint.new(@namespace.const_get(string))
ClassEndpoint.new(Utils::Class.load!(string, @namespace))
rescue NameError
LazyEndpoint.new(string, @namespace)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lotus/routing/resource/action.rb
Expand Up @@ -29,7 +29,7 @@ def prefix

private
def self.class_for(action)
Resource.const_get Utils::String.new(action).classify
Utils::Class.load!(Utils::String.new(action).classify, Resource)
end

def path
Expand Down
2 changes: 1 addition & 1 deletion lib/lotus/routing/resources/action.rb
Expand Up @@ -30,7 +30,7 @@ def prefix

private
def self.class_for(action)
Resources.const_get Utils::String.new(action).classify
Utils::Class.load!(Utils::String.new(action).classify, Resources)
end

def path
Expand Down

0 comments on commit ee8108b

Please sign in to comment.