class JsRoutes::Configuration
Attributes
Public Class Methods
Source
# File lib/js_routes/configuration.rb, line 47 def initialize(attributes = nil) @namespace = nil @exclude = T.let([], Clusivity) @include = T.let([//], Clusivity) @file = T.let(nil, FileName) @prefix = T.let(-> { Rails.application.config.relative_url_root || "" }, T.untyped) @url_links = T.let(false, T::Boolean) @camel_case = T.let(false, T::Boolean) @default_url_options = T.let(T.unsafe({}), Options) @compact = T.let(false, T::Boolean) @serializer = T.let(nil, T.nilable(String)) @special_options_key = T.let("_options", Literal) @application = T.let(T.unsafe(-> { Rails.application }), ApplicationCaller) @module_type = T.let('ESM', T.nilable(String)) @documentation = T.let(true, T::Boolean) @optional_definition_params = T.let(false, T::Boolean) @banner = T.let(default_banner, BannerCaller) return unless attributes assign(attributes) end
Public Instance Methods
Source
# File lib/js_routes/configuration.rb, line 90 def [](attribute) public_send(attribute) end
Source
# File lib/js_routes/configuration.rb, line 74 def assign(attributes) if attributes attributes.each do |attribute, value| public_send(:"#{attribute}=", value) end end normalize_and_verify self end
Source
# File lib/js_routes/configuration.rb, line 110 def dts? self.module_type === 'DTS' end
Source
# File lib/js_routes/configuration.rb, line 100 def merge(attributes) clone.assign(attributes) end
Source
# File lib/js_routes/configuration.rb, line 130 def output_file shakapacker = JsRoutes::Utils.shakapacker shakapacker_dir = shakapacker ? shakapacker.config.source_path : pathname('app', 'javascript') sprockets_dir = pathname('app','assets','javascripts') file_name = file || default_file_name sprockets_file = sprockets_dir.join(file_name) webpacker_file = shakapacker_dir.join(file_name) !Dir.exist?(shakapacker_dir) && defined?(::Sprockets) ? sprockets_file : webpacker_file end
Source
# File lib/js_routes/configuration.rb, line 94 def prefix=(value) JsRoutes::Utils.deprecator.warn("JsRoutes configuration prefix is deprecated in favor of default_url_options.script_name.") @prefix = value end
Source
# File lib/js_routes/configuration.rb, line 120 def require_esm raise "ESM module type is required" unless modern? end
Source
# File lib/js_routes/configuration.rb, line 85 def setup(&block) tap(&block) end
Source
# File lib/js_routes/configuration.rb, line 125 def source_file File.dirname(__FILE__) + "/../" + default_file_name end
Protected Instance Methods
Source
# File lib/js_routes/configuration.rb, line 155 def default_file_name dts? ? "routes.d.ts" : "routes.js" end
Source
# File lib/js_routes/configuration.rb, line 160 def normalize self.module_type = module_type&.upcase || 'NIL' end
Source
# File lib/js_routes/configuration.rb, line 144 def normalize_and_verify normalize verify end
Source
# File lib/js_routes/configuration.rb, line 150 def pathname(*parts) Pathname.new(File.join(*T.unsafe(parts))) end
Source
# File lib/js_routes/configuration.rb, line 165 def verify if module_type != 'NIL' && namespace raise "JsRoutes namespace option can only be used if module_type is nil" end end