Created
December 13, 2016 06:58
-
-
Save siassaj/73fabb81cb2890adde4dbef32470740d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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