Class: Notifly::ActionViewHelper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActionViewHelper

Returns a new instance of ActionViewHelper.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/services/action_view_helper.rb', line 6

def initialize
  notifly_path = File.expand_path(File.dirname(File.dirname(__FILE__))) + '../../app/views/notifly'
  rails_path = File.join(Rails.root, 'app/views/notifly')

  ActionController::Base.prepend_view_path(notifly_path)
  ActionController::Base.prepend_view_path(rails_path)

  @action_view = ActionView::Base.new(ActionController::Base.view_paths)
  @action_view.extend ApplicationHelper

  @action_view.class_eval do
    include Notifly::Engine.routes.url_helpers
    Dir[File.join(Rails.root, 'app/helpers/**/*.rb')].each do |f|
      require f
      include f.split('/').last.split('.').first.camelize.constantize
    end

    def protect_against_forgery?
      false
    end

    def main_app
      Rails.application.routes.url_helpers
    end
  end
end

Instance Attribute Details

#action_viewObject (readonly)

Returns the value of attribute action_view.



3
4
5
# File 'lib/services/action_view_helper.rb', line 3

def action_view
  @action_view
end