Method: LeanWeb::Route#seed_path

Defined in:
lib/leanweb/route.rb

#seed_path(seed) ⇒ String

On Regexp paths, return a string valid for making a request to this route.

Parameters:

  • seed (Array, Hash)

    Seeds to use as replacement on capture groups.

Returns:

  • (String)

    sown path.



88
89
90
91
92
93
94
95
96
# File 'lib/leanweb/route.rb', line 88

def seed_path(seed)
  sown_path = str_path
  if seed.instance_of?(Hash)
    seed.each{ |key, val| sown_path.sub!(/\(\?<#{key}>[^)]+\)/, val) }
  else
    seed.each{ |val| sown_path.sub!(/\([^)]+\)/, val) }
  end
  sown_path
end