Skip to content

Instantly share code, notes, and snippets.

@siassaj
Created December 13, 2016 06:58
Show Gist options
  • Select an option

  • Save siassaj/73fabb81cb2890adde4dbef32470740d to your computer and use it in GitHub Desktop.

Select an option

Save siassaj/73fabb81cb2890adde4dbef32470740d to your computer and use it in GitHub Desktop.
class ApplicationDelegate
include Rails.application.routes.url_helpers
default_url_options[:host] = ActionMailer::Base.default_url_options[:host]
attr_reader :c
def initialize(controller)
@c = controller
end
def call
if delegate?
run
return true
else
return false
end
end
private
def export(variables)
variables.each do |key, value|
c.instance_variable_set "@#{key}", value
end
end
def cookies
c.send :cookies
end
def redirect_to(*opts)
c.send :redirect_to, *opts
end
def render(*opts)
c.send :render, *opts
end
def gon
c.send :gon
end
def authorize(*opts)
c.send :authorize, *opts
end
def current_user
c.send :current_user
end
def user_signed_in?
c.send :user_signed_in?
end
def params
c.send :params
end
def controller_path
c.send :controller_path
end
def action_name
c.send :action_name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment