Class: ActiveRecord::Associations::AssociationProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/portable_model/active_record.rb

Instance Method Summary collapse

Instance Method Details

#export_to_yml(filename) ⇒ Object

Export the association to a YAML file.



26
27
28
29
30
31
32
# File 'lib/portable_model/active_record.rb', line 26

def export_to_yml(filename)
  NotPortableError.raise_on_not_portable(self)

  Pathname.new(filename).open('w') do |out|
    YAML::dump(export_portable_association, out)
  end
end

#import_from_yml(filename) ⇒ Object

Import the association from a YAML file.



36
37
38
39
# File 'lib/portable_model/active_record.rb', line 36

def import_from_yml(filename)
  NotPortableError.raise_on_not_portable(self)
  import_portable_association(YAML::load_file(filename))
end