Class: JsFromRoutes::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Configuration

Returns a new instance of Configuration.



143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/js_from_routes/generator.rb', line 143

def initialize(root)
  dir = %w[frontend packs javascript assets].find { |dir| root.join("app", dir).exist? }
  @all_helpers_file = true
  @client_library = "@js-from-routes/client"
  @export_if = ->(route) { route.defaults.fetch(:export, nil) }
  @file_suffix = "Api.js"
  @helper_mappings = {}
  @output_folder = root.join("app", dir, "api")
  @template_path = File.expand_path("template.js.erb", __dir__)
  @template_all_path = File.expand_path("template_all.js.erb", __dir__)
  @template_index_path = File.expand_path("template_index.js.erb", __dir__)
end

Instance Attribute Details

#all_helpers_fileObject

Returns the value of attribute all_helpers_file.



139
140
141
# File 'lib/js_from_routes/generator.rb', line 139

def all_helpers_file
  @all_helpers_file
end

#client_libraryObject

Returns the value of attribute client_library.



139
140
141
# File 'lib/js_from_routes/generator.rb', line 139

def client_library
  @client_library
end

#export_ifObject

Returns the value of attribute export_if.



139
140
141
# File 'lib/js_from_routes/generator.rb', line 139

def export_if
  @export_if
end

#file_suffixObject

Returns the value of attribute file_suffix.



139
140
141
# File 'lib/js_from_routes/generator.rb', line 139

def file_suffix
  @file_suffix
end

#helper_mappingsObject

Returns the value of attribute helper_mappings.



139
140
141
# File 'lib/js_from_routes/generator.rb', line 139

def helper_mappings
  @helper_mappings
end

#output_folderObject

Returns the value of attribute output_folder.



139
140
141
# File 'lib/js_from_routes/generator.rb', line 139

def output_folder
  @output_folder
end

#template_all_pathObject

Returns the value of attribute template_all_path.



139
140
141
# File 'lib/js_from_routes/generator.rb', line 139

def template_all_path
  @template_all_path
end

#template_index_pathObject

Returns the value of attribute template_index_path.



139
140
141
# File 'lib/js_from_routes/generator.rb', line 139

def template_index_path
  @template_index_path
end

#template_pathObject

Returns the value of attribute template_path.



139
140
141
# File 'lib/js_from_routes/generator.rb', line 139

def template_path
  @template_path
end