class InlineSvg::Configuration
Attributes
asset_file[R]
asset_finder[R]
custom_transformations[R]
svg_not_found_css_class[R]
Public Class Methods
new()
click to toggle source
# File lib/inline_svg.rb, line 24 def initialize @custom_transformations = {} @asset_file = InlineSvg::AssetFile @svg_not_found_css_class = nil @raise_on_file_not_found = false end
Public Instance Methods
add_custom_transformation(options)
click to toggle source
# File lib/inline_svg.rb, line 64 def add_custom_transformation(options) if incompatible_transformation?(options.fetch(:transform)) raise InlineSvg::Configuration::Invalid.new("#{options.fetch(:transform)} should implement the .create_with_value and #transform methods") end @custom_transformations.merge!(Hash[ *[options.fetch(:attribute, :no_attribute), options] ]) end
asset_file=(custom_asset_file)
click to toggle source
# File lib/inline_svg.rb, line 31 def asset_file=(custom_asset_file) begin method = custom_asset_file.method(:named) if method.arity == 1 @asset_file = custom_asset_file else raise InlineSvg::Configuration::Invalid.new("asset_file should implement the #named method with arity 1") end rescue NameError raise InlineSvg::Configuration::Invalid.new("asset_file should implement the #named method") end end
asset_finder=(finder)
click to toggle source
# File lib/inline_svg.rb, line 44 def asset_finder=(finder) @asset_finder = if finder.respond_to?(:find_asset) finder elsif finder.class.name == "Propshaft::Assembly" InlineSvg::PropshaftAssetFinder else # fallback to a naive static asset finder # (sprokects >= 3.0 && config.assets.precompile = false # See: https://github.com/jamesmartin/inline_svg/issues/25 InlineSvg::StaticAssetFinder end asset_finder end
raise_on_file_not_found=(value)
click to toggle source
# File lib/inline_svg.rb, line 71 def raise_on_file_not_found=(value) @raise_on_file_not_found = value end
raise_on_file_not_found?()
click to toggle source
# File lib/inline_svg.rb, line 75 def raise_on_file_not_found? !!@raise_on_file_not_found end
svg_not_found_css_class=(css_class)
click to toggle source
# File lib/inline_svg.rb, line 58 def svg_not_found_css_class=(css_class) if css_class.present? && css_class.is_a?(String) @svg_not_found_css_class = css_class end end
Private Instance Methods
incompatible_transformation?(klass)
click to toggle source
# File lib/inline_svg.rb, line 81 def incompatible_transformation?(klass) !klass.is_a?(Class) || !klass.respond_to?(:create_with_value) || !klass.instance_methods.include?(:transform) end