Module: LiveFixtures::Export::Fixture
- Defined in:
- lib/live_fixtures/export/fixture.rb
Overview
Exposes functionality to serialize an ActiveRecord record (a model) into a YAML fixture.
Class Method Summary collapse
-
.to_yaml(model, references = [], more_attributes = {}) ⇒ String
YAML-Serializes the provided model, including any references and additional attribtues.
Class Method Details
.to_yaml(model, references = [], more_attributes = {}) ⇒ String
YAML-Serializes the provided model, including any references and additional attribtues.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/live_fixtures/export/fixture.rb', line 11 def to_yaml(model, references = [], more_attributes = {}) table_name = model.class.table_name more_attributes.merge! attributes_from_references(model, references) <<-YML #{table_name}_#{model.id || SecureRandom.uuid.underscore}: #{yml_attributes(model, more_attributes)} YML end |