Class: Usher::Util::Generators::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/usher/util/generate.rb

Direct Known Subclasses

URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#usherObject

Returns the value of attribute usher.



6
7
8
# File 'lib/usher/util/generate.rb', line 6

def usher
  @usher
end

Instance Method Details

#generate(name, params) ⇒ Object



8
9
10
# File 'lib/usher/util/generate.rb', line 8

def generate(name, params)
  generate_path_for_base_params(@usher.named_routes[name].find_matching_path(params), params)
end

#generate_path_for_base_params(path, params) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/usher/util/generate.rb', line 12

def generate_path_for_base_params(path, params)
  raise UnrecognizedException.new unless path
  case params
  when nil, Hash
    path.generate_from_hash(params)
  else
    path.generate(*Array(params).slice!(0, path.dynamic_parts.size))
  end
end