class Fixturator::Configuration

Attributes

models[R]

Public Class Methods

load() click to toggle source
# File lib/fixturator/configuration.rb, line 7
def load
  hash = YAML.safe_load(config_file)
  hash ? new(**hash.symbolize_keys!) : new
end
new(models: [], exclude_timestamps: false) click to toggle source
# File lib/fixturator/configuration.rb, line 24
def initialize(models: [], exclude_timestamps: false)
  @models = models.map(&Model.method(:new)).compact
  exclude_timestamps_from(@models) if exclude_timestamps
end

Private Class Methods

config_file() click to toggle source
# File lib/fixturator/configuration.rb, line 14
def config_file
  return "" unless File.exist?(config_path)
  File.read(config_path)
end
config_path() click to toggle source
# File lib/fixturator/configuration.rb, line 19
def config_path
  Rails.root.join("config", "fixturator.yml")
end

Private Instance Methods

exclude_timestamps_from(models) click to toggle source
# File lib/fixturator/configuration.rb, line 33
def exclude_timestamps_from(models)
  models.each { |model| model.excluded_attributes.concat(timestamps) }
end
timestamps() click to toggle source
# File lib/fixturator/configuration.rb, line 37
def timestamps
  %w(created_at updated_at)
end