Module: RecordLoader

Defined in:
lib/record_loader.rb,
lib/record_loader/base.rb,
lib/record_loader/filter.rb,
lib/record_loader/adapter.rb,
lib/record_loader/railtie.rb,
lib/record_loader/version.rb,
lib/record_loader/attribute.rb,
lib/record_loader/record_file.rb,
lib/record_loader/adapter/basic.rb,
lib/record_loader/adapter/rails.rb,
lib/record_loader/filter/standard.rb,
lib/record_loader/filter/file_list.rb,
lib/generators/record_loader/static_files/application_record_loader.rb

Overview

This file was automatically generated by rails g record_loader

Defined Under Namespace

Modules: Adapter, Filter Classes: ApplicationRecordLoader, Attribute, Base, Railtie, RecordFile

Constant Summary collapse

ConfigurationError =

Raised when it appears RecordLoader is improperly configured

Class.new(StandardError)
VERSION =

Returns The current sem-ver version number.

Returns:

  • (String)

    The current sem-ver version number

'0.2.0'

Class Method Summary collapse

Class Method Details

.export_attributes(model_class, key) ⇒ String

Helper method to automatically generate config yaml for existing data. This method does not handle setting up associations as the best way of serializing that information is left up to the individual RecordLoader

Parameters:

  • model_class (ActiveRecord::Base)

    A class to serialize

  • key (String)

    The key to index by (eg. 'name')

Returns:

  • (String)

    Yaml listing the existing records



25
26
27
28
29
# File 'lib/record_loader.rb', line 25

def self.export_attributes(model_class, key)
  model_class.all.each_with_object({}) do |record, store|
    store[record[key]] = record.attributes.except('id', 'updated_at', 'created_at', key)
  end.to_yaml
end