Module: Swamp::Action::Routes

Defined in:
lib/swamp/rails_actions/action/routes.rb

Instance Method Summary collapse

Instance Method Details

#path(name, options = Hash[]) ⇒ Object



9
10
11
# File 'lib/swamp/rails_actions/action/routes.rb', line 9

def path(name, options = Hash[])
  router.send(:"#{name}_path", router_default_url_options.merge(options))
end

#routerObject



5
6
7
# File 'lib/swamp/rails_actions/action/routes.rb', line 5

def router
  @router ||= Rails.application.routes
end

#router_default_url_optionsObject



17
18
19
20
21
# File 'lib/swamp/rails_actions/action/routes.rb', line 17

def router_default_url_options
  Hash[].tap do |opts|
    opts[:host] = @request.host if @request
  end
end

#url(name, options = Hash[]) ⇒ Object



13
14
15
# File 'lib/swamp/rails_actions/action/routes.rb', line 13

def url(name, options = Hash[])
  router.send(:"#{name}_url", router_default_url_options.merge(options))
end