Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Move instance methods to avoid deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeltrix committed Oct 6, 2012
1 parent f6ac128 commit c92186c
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions lib/rails_legacy_mapper/route_set_extensions.rb
Expand Up @@ -13,40 +13,38 @@ module RouteSetExtensions #:nodoc:
alias_method_chain :eval_block, :legacy_mapper
end

module InstanceMethods #:nodoc:
def initialize_with_legacy_mapper(request_class = ActionDispatch::Request)
initialize_without_legacy_mapper
self.controller_namespaces = Set.new
end
def initialize_with_legacy_mapper(request_class = ActionDispatch::Request)
initialize_without_legacy_mapper
self.controller_namespaces = Set.new
end

def controller_constraints
@controller_constraints ||= begin
namespaces = controller_namespaces + in_memory_controller_namespaces
source = namespaces.map { |ns| "#{Regexp.escape(ns)}/#{CONTROLLER_REGEXP.source}" }
source << CONTROLLER_REGEXP.source
Regexp.compile(source.sort.reverse.join('|'))
end
def controller_constraints
@controller_constraints ||= begin
namespaces = controller_namespaces + in_memory_controller_namespaces
source = namespaces.map { |ns| "#{Regexp.escape(ns)}/#{CONTROLLER_REGEXP.source}" }
source << CONTROLLER_REGEXP.source
Regexp.compile(source.sort.reverse.join('|'))
end
end

def in_memory_controller_namespaces
namespaces = Set.new
ActionController::Base.descendants.each do |klass|
next if klass.anonymous?
namespaces << klass.name.underscore.split('/')[0...-1].join('/')
end
namespaces.delete('')
namespaces
def in_memory_controller_namespaces
namespaces = Set.new
ActionController::Base.descendants.each do |klass|
next if klass.anonymous?
namespaces << klass.name.underscore.split('/')[0...-1].join('/')
end
namespaces.delete('')
namespaces
end

def eval_block_with_legacy_mapper(block)
mapper = ActionDispatch::Routing::Mapper.new(self)
if block.arity == 1
mapper.instance_exec(RailsLegacyMapper::Mapper.new(self), &block)
elsif default_scope
mapper.with_default_scope(default_scope, &block)
else
mapper.instance_exec(&block)
end
def eval_block_with_legacy_mapper(block)
mapper = ActionDispatch::Routing::Mapper.new(self)
if block.arity == 1
mapper.instance_exec(RailsLegacyMapper::Mapper.new(self), &block)
elsif default_scope
mapper.with_default_scope(default_scope, &block)
else
mapper.instance_exec(&block)
end
end
end
Expand Down

0 comments on commit c92186c

Please sign in to comment.