Class: InlineSvg::Configuration

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

Defined Under Namespace

Classes: Invalid

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



21
22
23
24
25
26
# File 'lib/inline_svg.rb', line 21

def initialize
  @custom_transformations = {}
  @asset_file = InlineSvg::AssetFile
  @svg_not_found_css_class = nil
  @raise_on_file_not_found = false
end

Instance Attribute Details

#asset_fileObject

Returns the value of attribute asset_file.



19
20
21
# File 'lib/inline_svg.rb', line 19

def asset_file
  @asset_file
end

#asset_finderObject

Returns the value of attribute asset_finder.



19
20
21
# File 'lib/inline_svg.rb', line 19

def asset_finder
  @asset_finder
end

#custom_transformationsObject (readonly)

Returns the value of attribute custom_transformations.



19
20
21
# File 'lib/inline_svg.rb', line 19

def custom_transformations
  @custom_transformations
end

#svg_not_found_css_classObject

Returns the value of attribute svg_not_found_css_class.



19
20
21
# File 'lib/inline_svg.rb', line 19

def svg_not_found_css_class
  @svg_not_found_css_class
end

Instance Method Details

#add_custom_transformation(options) ⇒ Object



59
60
61
62
63
64
# File 'lib/inline_svg.rb', line 59

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

#raise_on_file_not_found=(value) ⇒ Object



66
67
68
# File 'lib/inline_svg.rb', line 66

def raise_on_file_not_found=(value)
  @raise_on_file_not_found = value
end

#raise_on_file_not_found?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/inline_svg.rb', line 70

def raise_on_file_not_found?
  !!@raise_on_file_not_found
end