class Scaffold::Services::Path
Public Class Methods
new(rails)
click to toggle source
# File lib/scaffold/services/path.rb, line 4 def initialize rails @rails = rails end
Public Instance Methods
collection()
click to toggle source
# File lib/scaffold/services/path.rb, line 48 def collection segments = [] segments += namespace_segments if @rails.controller.namespaced? segments += nested_resource_segments if @rails.route.nested? segments << ":#{@rails.resource.collection_name}" "[#{segments.join(', ')}]" end
edit_instance_resource()
click to toggle source
# File lib/scaffold/services/path.rb, line 40 def edit_instance_resource segments = [':edit'] segments += namespace_segments if @rails.controller.namespaced? segments += nested_resource_segments if @rails.route.nested? segments << "@#{@rails.resource.name}" "[#{segments.join(', ')}]" end
edit_resource()
click to toggle source
# File lib/scaffold/services/path.rb, line 24 def edit_resource segments = [':edit'] segments += namespace_segments if @rails.controller.namespaced? segments += nested_resource_segments if @rails.route.nested? segments << @rails.resource.name "[#{segments.join(', ')}]" end
instance_resource()
click to toggle source
# File lib/scaffold/services/path.rb, line 32 def instance_resource segments = [] segments += namespace_segments if @rails.controller.namespaced? segments += nested_resource_segments if @rails.route.nested? segments << "@#{@rails.resource.name}" "[#{segments.join(', ')}]" end
new_resource()
click to toggle source
# File lib/scaffold/services/path.rb, line 8 def new_resource segments = [':new'] segments += namespace_segments if @rails.controller.namespaced? segments += nested_resource_segments if @rails.route.nested? segments << ":#{@rails.resource.name}" "[#{segments.join(', ')}]" end
resource()
click to toggle source
# File lib/scaffold/services/path.rb, line 16 def resource segments = [] segments += namespace_segments if @rails.controller.namespaced? segments += nested_resource_segments if @rails.route.nested? segments << @rails.resource.name "[#{segments.join(', ')}]" end
Private Instance Methods
namespace_segments()
click to toggle source
- “:admin”, “:companies”
# File lib/scaffold/services/path.rb, line 59 def namespace_segments @rails.controller.namespaces_as_path.map{|segment| ":#{segment}".to_sym } end
nested_resource_segments()
click to toggle source
- client
# File lib/scaffold/services/path.rb, line 64 def nested_resource_segments @rails.nested_in_resources.collect do |nested_resource| nested_resource.name end end