Skip to content

Commit

Permalink
Implemented #request_path and #nesting_request_path
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Sep 19, 2009
1 parent c75269d commit b0eb3ad
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/ardes/resources_controller/request_path_introspection.rb
@@ -0,0 +1,24 @@
module Ardes
module ResourcesController
module RequestPathIntrospection

protected
def request_path
@request_path ||= params[:resource_path] || request.path
end

def nesting_request_path
@nesting_request_path ||= remove_namespace(request_path.sub(%r(/#{resource_segment}(?!.*/#{resource_segment}).*$), ''))
end

private
def resource_segment
respond_to?(:resource_specification) ? resource_specification.segment : controller_name
end

def remove_namespace(path)
(controller_path != controller_name) ? path.sub(%r(^/#{controller_path.sub(%r(/#{controller_name}), '')}), '') : path
end
end
end
end

0 comments on commit b0eb3ad

Please sign in to comment.