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.



122
123
124
# File 'app/helpers/rails_pulse/application_helper.rb', line 122

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



127
128
129
130
131
132
133
# File 'app/helpers/rails_pulse/application_helper.rb', line 127

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



140
141
142
# File 'app/helpers/rails_pulse/application_helper.rb', line 140

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

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

Returns:

  • (Boolean)


135
136
137
# File 'app/helpers/rails_pulse/application_helper.rb', line 135

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