Class: ActiveExport::Yaml

Inherits:
Base
  • Object
show all
Defined in:
lib/active_export/yaml.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #eval_methods, #label_keys, #label_prefix, #namespace, #options, #source, #source_name

Instance Method Summary collapse

Methods inherited from Base

build_label_keys_and_eval_methods, #build_label_keys_and_eval_methods!, #convert, #default_scope, export, #export_data, export_file, #find_in_batches_options, #generate_header, #generate_value, #initialize, #key_name, translate, #translate

Constructor Details

This class inherits a constructor from ActiveExport::Base

Instance Method Details

#export(data) ⇒ String

-

- label: value
- label: value

Returns:

  • (String)

    YAML style string



12
13
14
15
16
# File 'lib/active_export/yaml.rb', line 12

def export(data)
  [].tap {|o|
    export_data(data, o)
  }.to_yaml
end

#export_file(data, filename) ⇒ Object



18
19
20
21
22
# File 'lib/active_export/yaml.rb', line 18

def export_file(data, filename)
  File.atomic_write(filename.to_s) do |file|
    file.write export(data)
  end
end