Class: RailsPulse::ApplicationHelper::RailsPulseHelper

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/rails_pulse/application_helper.rb

Overview

Helper class to provide both routes and asset methods

Instance Method Summary collapse

Constructor Details

#initialize(view_context) ⇒ RailsPulseHelper

Returns a new instance of RailsPulseHelper.



91
92
93
# File 'app/helpers/rails_pulse/application_helper.rb', line 91

def initialize(view_context)
  @view_context = view_context
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Delegate route methods to engine routes



96
97
98
99
100
101
102
# File 'app/helpers/rails_pulse/application_helper.rb', line 96

def method_missing(method, *args, &block)
  if RailsPulse::Engine.routes.url_helpers.respond_to?(method)
    RailsPulse::Engine.routes.url_helpers.send(method, *args, &block)
  else
    super
  end
end

Instance Method Details

#asset_path(asset_name) ⇒ Object

Generate asset paths that work with our custom asset serving



109
110
111
# File 'app/helpers/rails_pulse/application_helper.rb', line 109

def asset_path(asset_name)
  "/rails-pulse-assets/#{asset_name}"
end

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

Returns:

  • (Boolean)


104
105
106
# File 'app/helpers/rails_pulse/application_helper.rb', line 104

def respond_to_missing?(method, include_private = false)
  RailsPulse::Engine.routes.url_helpers.respond_to?(method, include_private) || super
end