class RemoveDataAttributes::Configuration

Constants

SUPPORTED_FILE_FORMATS

Attributes

data_attributes[W]

Public Class Methods

from_file(filename) click to toggle source
# File lib/remove_data_attributes/configuration.rb, line 15
def from_file(filename)
  loader = loader_for(::File.extname(filename))

  unless loader
    message = "This file format is not supported."
    raise ::RemoveDataAttributes::InvalidConfiguration, message
  end

  ::File.open(filename) { |file| new(loader.load(file)) }
end
new(attributes = {}) click to toggle source

:reek: ManualDispatch

# File lib/remove_data_attributes/configuration.rb, line 41
def initialize(attributes = {})
  attributes.each do |attribute_name, value|
    method_name = "#{attribute_name}="
    public_send(method_name, value) if respond_to?(method_name)
  end
end
supported_file_extensions() click to toggle source
# File lib/remove_data_attributes/configuration.rb, line 26
def supported_file_extensions
  @supported_file_extensions ||= SUPPORTED_FILE_FORMATS.values.flatten.sort
end

Private Class Methods

loader_for(extname) click to toggle source

:reek: ControlParameter

# File lib/remove_data_attributes/configuration.rb, line 33
def loader_for(extname)
  case extname
  when *SUPPORTED_FILE_FORMATS["YAML"] then ::YAML
  end
end

Public Instance Methods

data_attributes() click to toggle source
# File lib/remove_data_attributes/configuration.rb, line 48
def data_attributes
  @data_attributes ||= []
end