Sha256: 57a92658fdea8d1c5c608cf77c6d64a793748fb1446992e72750705f753100a2
Contents?: true
Size: 920 Bytes
Versions: 2
Compression:
Stored size: 920 Bytes
Contents
require 'route_dog/middleware' require 'route_dog/railtie' if defined?(Rails) module RouteDog def self.config_file File.join(Rails.root, 'config', 'route_dog_routes.yml') end def self.load_watched_routes YAML.load_file(config_file) rescue Errno::ENOENT {} end def self.write_watched_routes(routes) File.open(config_file, "w+") {|file| file.puts(routes.to_yaml) } end # When method.nil? it respond to all methods. def self.route_tested?(controller, action, method) begin available_methods = load_watched_routes[controller.to_s.downcase][action.to_s.downcase] method.nil? ? available_methods.any? : available_methods.include?(method.to_s.downcase) rescue false end end def self.constantize_controller_str(controller) controller.split("/").map{|c| c.split("_").map{|cc| cc.capitalize}.join }.join("::").concat("Controller").constantize end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
route_dog-2.3.1 | lib/route_dog.rb |
route_dog-2.3.0 | lib/route_dog.rb |