Sha256: 3587976bca054aaf2f1c134945e38a6bff471b69b255942e5f12f5eca0c5e89e
Contents?: true
Size: 845 Bytes
Versions: 1
Compression:
Stored size: 845 Bytes
Contents
require "to_fixture/version" require "active_support" require "active_record" module ToFixture module Base def to_fixture(label = nil) label = "#{self.class.table_name}_#{self.id}" unless label inspection = if defined?(@attributes) && @attributes columns_for_fixture.collect do |name| " #{name}: #{read_attribute(name)}" if has_attribute?(name) end.compact.join("\n") else "not initialized" end "#{label}:\n#{inspection}" end def columns_for_fixture self.class.column_names - all_timestamp_attributes.map(&:to_s) - %w(id) end end module Relation def to_fixture map(&:to_fixture).join("\n\n") end end end ActiveSupport.on_load(:active_record) do include ToFixture::Base ActiveRecord::Relation.include(ToFixture::Relation) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
to_fixture-0.2.0 | lib/to_fixture.rb |