Class: Helper

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

Class Method Summary collapse

Class Method Details

.helper_respondersObject



12
13
14
15
16
17
18
# File 'lib/rails_helper_anywhere.rb', line 12

def helper_responders
  [
    Rails.application.routes.url_helpers,
    ActionView::Base.new('app/views'),
    ApplicationController.helpers
  ]
end

.method_missing(method, *args, &block) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/rails_helper_anywhere.rb', line 20

def method_missing(method, *args, &block)
  helper_responders.each do |helper_responder|
    return helper_responder.send(method, *args, &block) if helper_responder.respond_to?(method)
  end

  super
end

.respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
# File 'lib/rails_helper_anywhere.rb', line 28

def respond_to_missing?(method, include_private = false)
  helper_responders.each do |helper_responder|
    return true if helper_responder.respond_to?(method, include_private)
  end

  super
end