Module: RailsJsHelper

Defined in:
lib/rails_js_helper.rb,
lib/rails_js_helper/engine.rb,
lib/rails_js_helper/version.rb,
lib/rails/generators/rails_js_helper/config/config_generator.rb

Defined Under Namespace

Classes: ConfigGenerator, Engine

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.asset_path_tableObject



16
17
18
19
20
21
22
23
# File 'lib/rails_js_helper.rb', line 16

def asset_path_table
  assets = load_config["assets"].to_a
  Hash[
    assets.map do |path|
      [path, ActionController::Base.helpers.image_path(path)]
    end
  ]
end

.config_tableObject



32
33
34
# File 'lib/rails_js_helper.rb', line 32

def config_table
  load_config["configs"] || {}
end

.image_path_tableObject



7
8
9
10
11
12
13
14
# File 'lib/rails_js_helper.rb', line 7

def image_path_table
  images = load_config["images"].to_a
  Hash[
    images.map do |path|
      [path, ActionController::Base.helpers.image_path(path)]
    end
  ]
end

.named_route_tableObject



25
26
27
28
29
30
# File 'lib/rails_js_helper.rb', line 25

def named_route_table
  Rails.application.routes.named_routes
    .select { |name, route| (route.parts - route.optional_parts).empty? }
    .map {|name, route| [name, Rails.application.routes.url_helpers.send("#{name}_path")] }
    .to_h
end