Class: Usher::Util::Generators::Generic
- Inherits:
-
Object
- Object
- Usher::Util::Generators::Generic
- Defined in:
- lib/usher/util/generate.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#usher ⇒ Object
Returns the value of attribute usher.
Instance Method Summary collapse
- #generate(name, params) ⇒ Object
- #generate_path_for_base_params(path, params) ⇒ Object
- #generate_path_for_base_params_with_array(path, params) ⇒ Object
- #generate_path_for_base_params_with_hash(path, params) ⇒ Object
Instance Attribute Details
#usher ⇒ Object
Returns the value of attribute usher.
7 8 9 |
# File 'lib/usher/util/generate.rb', line 7 def usher @usher end |
Instance Method Details
#generate(name, params) ⇒ Object
9 10 11 |
# File 'lib/usher/util/generate.rb', line 9 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
13 14 15 16 17 18 19 20 21 |
# File 'lib/usher/util/generate.rb', line 13 def generate_path_for_base_params(path, params) raise UnrecognizedException.new unless path case params when nil, Hash generate_path_for_base_params_with_hash(path, params) else generate_path_for_base_params_with_array(path, Array(params)) end end |
#generate_path_for_base_params_with_array(path, params) ⇒ Object
27 28 29 |
# File 'lib/usher/util/generate.rb', line 27 def generate_path_for_base_params_with_array(path, params) path.generate(*params.slice!(0, path.dynamic_parts.size)) end |
#generate_path_for_base_params_with_hash(path, params) ⇒ Object
23 24 25 |
# File 'lib/usher/util/generate.rb', line 23 def generate_path_for_base_params_with_hash(path, params) path.generate_from_hash(params) end |