BasicObject
# File lib/routing_filter/adapters/rails_2.rb, line 33 def add_filters(*names) options = names.extract_options! names.each { |name| filters.unshift(RoutingFilter.build(name, options)) } end
# File lib/routing_filter/filters/pagination.rb, line 43 def append_page?(page) page && page.to_i != 1 end
# File lib/routing_filter/adapters/rails_2.rb, line 49 def clear_with_filtering! @filters.clear if @filters clear_without_filtering! end
# File lib/routing_filter/filters/locale.rb, line 81 def default_locale?(locale) locale && locale.to_sym == I18n.default_locale.to_sym end
# File lib/routing_filter/filters/locale.rb, line 89 def excluded?(url) case exclude when Regexp url =~ exclude when Proc exclude.call(url) end end
# File lib/routing_filter/adapters/rails_2.rb, line 60 def extract_request_environment(request) extract_request_environment_without_host(request).tap do |env| env.merge! :host => request.host, :port => request.port, :host_with_port => request.host_with_port, :domain => request.domain, :subdomain => request.subdomains.first end end
# File lib/routing_filter/adapters/rails_2.rb, line 5 def filter(*args) @set.add_filters(*args) end
# File lib/routing_filter/adapters/rails_2.rb, line 29 def filters @filters ||= RoutingFilter::Chain.new end
# File lib/routing_filter/adapters/routers/journey.rb, line 11 def find_routes_with_filtering env path, filter_parameters = env['PATH_INFO'], {} @routes.filters.run(:around_recognize, path, env) do filter_parameters end find_routes_without_filtering(env).map do |match, parameters, route| [ match, parameters.merge(filter_parameters), route ] end end
gosh. monkey engineering optimization code
# File lib/routing_filter/adapters/rails_2.rb, line 13 def generate_optimisation_block_with_filtering(*args) code = generate_optimisation_block_without_filtering(*args) if match = code.match(%(^return (.*) if (.*))) # returned string must not contain newlines, or we'll spill out of inline code comments in # ActionController::Routing::RouteSet::NamedRouteCollection#define_url_helper "#{match[1]}.tap { |result|" + " ActionController::Routing::Routes.filters.run(:around_generate, *args, &lambda{ result }) " + "} if #{match[2]}" end end
# File lib/routing_filter/adapters/rails_2.rb, line 44 def generate_with_filtering(*args) filters.run(:around_generate, args.first, &lambda{ generate_without_filtering(*args) }) end
# File lib/routing_filter/adapters/routers/rack_mount.rb, line 13 def optimize_recognize_with_filtering! optimize_recognize_without_filtering! (class << self; self; end).class_eval do alias_method_chain :recognize, :filtering end end
# File lib/routing_filter/filters/locale.rb, line 85 def prepend_locale?(locale) locale && (self.class.include_default_locale? || !default_locale?(locale)) end
# File lib/routing_filter/adapters/rails_2.rb, line 38 def recognize_path_with_filtering(path, env = {}) path = ::URI.unescape(path.dup) # string is frozen due to memoize filters.run(:around_recognize, path, env, &lambda{ recognize_path_without_filtering(path, env) }) end
note: if you overly and unnecessarily use blocks in your lowlevel libraries you make it fricking hard for your users to hook in anywhere
# File lib/routing_filter/adapters/routers/rack_mount.rb, line 24 def recognize_with_filtering(request, &block) path, route, matches, params = request.env['PATH_INFO'], nil, nil, nil original_path = path.dup filters.run(:around_recognize, path, request.env) do route, matches, params = recognize_without_filtering(request) params || {} end request.env['PATH_INFO'] = original_path # hmm ... return nil unless route if block_given? return block.call(route, matches, params) else return route, matches, params end end
Generated with the Darkfish Rdoc Generator 2.