Class: JsFromRoutes::AllRoutes

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

Overview

Internal: Helper class used as a presenter for the all helpers template.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(helpers, config) ⇒ AllRoutes

Returns a new instance of AllRoutes.



15
16
17
# File 'lib/js_from_routes/generator.rb', line 15

def initialize(helpers, config)
  @helpers, @config = helpers, config
end

Instance Attribute Details

#helpersObject (readonly)

Returns the value of attribute helpers.



13
14
15
# File 'lib/js_from_routes/generator.rb', line 13

def helpers
  @helpers
end

Instance Method Details

#cache_keyObject

Public: Used to check whether the file should be generated again, changes based on the configuration, and route definition.



21
22
23
# File 'lib/js_from_routes/generator.rb', line 21

def cache_key
  helpers.map(&:import_filename).join + File.read(@config.template_all_path)
end

#filenameObject

Internal: Name of the JS file where all helpers will be exported.



26
27
28
29
30
# File 'lib/js_from_routes/generator.rb', line 26

def filename
  path = @config.all_helpers_file
  path = "index#{File.extname(@config.file_suffix)}" if path == true
  @config.output_folder.join(path)
end