class NotFoundCatcher::RequestStore
Attributes
path[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/not_found_catcher/request_store.rb, line 6 def initialize(path) self.path = path end
Public Instance Methods
each() { |store| ... }
click to toggle source
# File lib/not_found_catcher/request_store.rb, line 47 def each store.transaction(true) do store.roots.each do |k| yield store[k] end end end
find(key)
click to toggle source
# File lib/not_found_catcher/request_store.rb, line 61 def find(key) rule = nil store.transaction(true) do store.roots.each do |k| rule = store[k] if store[k].id == key end end rule end
find_by_redirect(key)
click to toggle source
# File lib/not_found_catcher/request_store.rb, line 71 def find_by_redirect(key) rule = nil store.transaction(true) do store.roots.each do |k| rule = store[k] if store[k].redirect == key end end rule end
get_first_match(path)
click to toggle source
Restituisce la prima chiave matchata
# File lib/not_found_catcher/request_store.rb, line 32 def get_first_match(path) store.transaction(true) do store.roots.each do |k| if path.match(k) return k end end end false end
parse(request) { |req| ... }
click to toggle source
# File lib/not_found_catcher/request_store.rb, line 11 def parse(request) key = get_first_match(request.fullpath) store.transaction do if key req = store[key] else req = store[request.fullpath] = NotFoundCatcher::RequestParser.new(request.fullpath, request.request_method, nil) end yield req end end
store()
click to toggle source
Store yaml
# File lib/not_found_catcher/request_store.rb, line 83 def store @_store ||= YAML::Store.new self.path end