module Rack::Way::Action

Public Class Methods

erb(path, params = {}) click to toggle source
# File lib/rack-way/action.rb, line 48
def erb(path, params = {})
  Erubis::FastEruby
      .load_file("#{path}.html.erb")
      .result(params)
end
redirect_to(url) click to toggle source
# File lib/rack-way/action.rb, line 54
def redirect_to(url)
  [302, {'Location' => url}, []]
end
render(content, headers: {"Content-Type" => "text/html"}, status: 200) click to toggle source
# File lib/rack-way/action.rb, line 29
def render(content, headers: {"Content-Type" => "text/html"}, status: 200)
  [status, headers, [content]]
end
render_erb(paths, params = {}, status: 200) click to toggle source
# File lib/rack-way/action.rb, line 33
def render_erb(paths, params = {}, status: 200)
  if paths.kind_of?(Array)
    erb =
      paths.map { |path| erb(path, params) }.join
  else
    erb = erb(paths, params)
  end

  [status, {"Content-Type" => "text/html"}, [erb]]
end
render_json(content = {}, status: 200) click to toggle source
# File lib/rack-way/action.rb, line 44
def render_json(content = {}, status: 200)
  [status, {"Content-Type" => "application/json"}, [content.to_json]]
end

Public Instance Methods

erb(path, params = {}) click to toggle source
# File lib/rack-way/action.rb, line 20
def erb(path, params = {})
  Rack::Way::Action.erb(path, params)
end
redirect_to(url) click to toggle source
# File lib/rack-way/action.rb, line 24
def redirect_to(url)
  Rack::Way::Action.redirect_to(url)
end
render(content, headers: {"Content-Type" => "text/html"}, status: 200) click to toggle source
# File lib/rack-way/action.rb, line 8
def render(content, headers: {"Content-Type" => "text/html"}, status: 200)
  Rack::Way::Action.render(content, headers: headers, status: status)
end
render_erb(path, params = {}, status: 200) click to toggle source
# File lib/rack-way/action.rb, line 12
def render_erb(path, params = {}, status: 200)
  Rack::Way::Action.render_erb(path, params, status: status)
end
render_json(content = {}, status: 200) click to toggle source
# File lib/rack-way/action.rb, line 16
def render_json(content = {}, status: 200)
  Rack::Way::Action.render_json(content, status: status)
end