Sha256: e62d7c75e854e78c5e669bd990869dd6ec8e344b7be92a0477c5fc98235112fa
Contents?: true
Size: 877 Bytes
Versions: 2
Compression:
Stored size: 877 Bytes
Contents
module YARD::Templates::Helpers module RouteHelper def self.routes_for(prefix) Rails.application.routes.set end def self.matches_controller_and_action?(route, controller, action) route.requirements[:controller] == controller && route.requirements[:action] == action end def self.api_methods_for_controller_and_action(controller, action) @routes ||= self.routes_for('/') controller_path = [ YARD::APIPlugin.options.route_namespace, controller ].join('/') controller_path.gsub!(/^\/|_controller$/, '') @routes.find_all { |r| matches_controller_and_action?(r, controller_path, action) } end def self.get_route_path(route) route.path.spec.to_s.gsub("(.:format)", "") end def self.get_route_verb(route) route.verb.source =~ /\^?(\w*)\$/ ? $1.upcase : route.verb.source end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yard-api-0.3.0 | lib/yard-api/templates/helpers/route_helper.rb |
yard-api-0.2.3 | lib/yard-api/templates/helpers/route_helper.rb |