class Aygabtu::RouteWrapper
Attributes
journey_route[R]
Wraps a Journey route
marks[R]
Public Class Methods
new(journey_route)
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 7 def initialize(journey_route) @journey_route = journey_route @marks = [] end
Public Instance Methods
action()
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 50 def action # sanity condition needed for Rails 4.1 @journey_route.requirements[:action] if controller end
conflicting_marks(mark)
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 13 def conflicting_marks(mark) @marks.select { |m| m.conflicting?(mark) } end
controller()
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 33 def controller @journey_route.requirements[:controller] end
controller_basename()
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 46 def controller_basename Pathname(controller).basename.to_s if controller end
controller_namespace()
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 37 def controller_namespace return @controller_namespace if defined? @controller_namespace return @controller_namespace = nil unless controller @controller_namespace = Pathname('/').join(controller).dirname.to_s[1..-1] @controller_namespace = nil if @controller_namespace.empty? @controller_namespace end
format(visiting_data)
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 76 def format(visiting_data) visiting_data = visiting_data.stringify_keys query_data = visiting_data.except(*@journey_route.parts.map(&:to_s)) visiting_data = visiting_data.except(*query_data.keys) visiting_data.symbolize_keys! # format expects symbols, but we deal with strings in all other places path = @journey_route.format(visiting_data) if query_data.empty? path else "#{path}?#{Rack::Utils.build_query(query_data)}" end end
generate_url_with_proper_parameters(parameters)
click to toggle source
this assumes parameters.keys == required_parts
# File lib/aygabtu/route_wrapper.rb, line 64 def generate_url_with_proper_parameters(parameters) @journey_route.format(parameters) end
get?()
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 19 def get? @journey_route.verb.match('GET') end
inspect()
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 68 def inspect if @journey_route.name "route named :#{@journey_route.name}" else "route matching #{@journey_route.path.to_regexp.inspect}" end end
internal?()
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 23 def internal? # this particular route is hard to filter by any sensible criterion @journey_route.path.to_regexp == %r{\A/assets} end
name()
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 55 def name @journey_route.name.to_s if @journey_route.name end
really_required_keys()
click to toggle source
# File lib/aygabtu/route_wrapper.rb, line 92 def really_required_keys @journey_route.path.required_names end
required_parts()
click to toggle source
array of parameter names (symbols) required for generating URL
# File lib/aygabtu/route_wrapper.rb, line 29 def required_parts @journey_route.required_parts end