Module: RailsConsolePro::ArrayExtensions
- Defined in:
- lib/rails_console_pro/active_record_extensions.rb
Overview
Array extensions for ActiveRecord collections
Instance Method Summary collapse
-
#export_to_file(file_path, format: nil) ⇒ Object
Export array to file.
-
#to_html_export(style: :default) ⇒ Object
Export array to HTML.
-
#to_json_export(pretty: true) ⇒ Object
Export array to JSON.
-
#to_yaml_export ⇒ Object
Export array to YAML.
Instance Method Details
#export_to_file(file_path, format: nil) ⇒ Object
Export array to file
101 102 103 |
# File 'lib/rails_console_pro/active_record_extensions.rb', line 101 def export_to_file(file_path, format: nil) FormatExporter.export_to_file(self, file_path, format: format) end |
#to_html_export(style: :default) ⇒ Object
Export array to HTML
91 92 93 94 95 96 97 98 |
# File 'lib/rails_console_pro/active_record_extensions.rb', line 91 def to_html_export(style: :default) title = if !empty? && first.is_a?(ActiveRecord::Base) "#{first.class.name} Collection (#{size} records)" else "Array (#{size} items)" end FormatExporter.to_html(self, title: title, style: style) end |
#to_json_export(pretty: true) ⇒ Object
Export array to JSON
81 82 83 |
# File 'lib/rails_console_pro/active_record_extensions.rb', line 81 def to_json_export(pretty: true) FormatExporter.to_json(self, pretty: pretty) end |
#to_yaml_export ⇒ Object
Export array to YAML
86 87 88 |
# File 'lib/rails_console_pro/active_record_extensions.rb', line 86 def to_yaml_export FormatExporter.to_yaml(self) end |