Class: Wallaby::UrlFor

Inherits:
Object
  • Object
show all
Defined in:
lib/services/wallaby/url_for.rb

Overview

Url helper

Class Method Summary collapse

Class Method Details

.handle(wallaby_engine, options) ⇒ String

Handle wallaby engine url properly.

Parameters:

  • wallaby_engine (ActionDispatch::Routing::RoutesProxy)
  • options (ActionController::Parameters, Hash)

Returns:

  • (String)

    url string for wallaby engine



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/services/wallaby/url_for.rb', line 9

def handle(wallaby_engine, options)
  # NOTE: DEPRECATION WARNING: You are calling a `*_path` helper with the
  # `only_path` option explicitly set to `false`.
  # This option will stop working on path helpers in Rails 5.
  # Use the corresponding `*_url` helper instead.
  hash = normalize_params(options).except(:only_path)
  case hash[:action]
  when 'index', 'create' then wallaby_engine.resources_path hash
  when 'new' then wallaby_engine.new_resource_path hash
  when 'edit' then wallaby_engine.edit_resource_path hash
  else wallaby_engine.resource_path hash
  end
end