class ActiveAdmin::Exportable::Exporter::AssociationStruct

Public Class Methods

new(record:, association_name:, remove_ids:, next_level_includes: nil) click to toggle source
# File lib/active_admin/exportable/exporter.rb, line 112
def initialize(record:, association_name:, remove_ids:, next_level_includes: nil)
  @next_level_includes = next_level_includes
  @reflection = record.association(association_name).reflection
  @association = record.send(association_name)
  @remove_ids = remove_ids
end

Public Instance Methods

data() click to toggle source
# File lib/active_admin/exportable/exporter.rb, line 119
def data
  {
    name: @reflection.name,
    inverse: @reflection.inverse_of&.name,
    foreign_key: @reflection.foreign_key,
    foreign_type: @reflection.foreign_type,
    kind: @reflection.class.name.match(/.*::(?<shortname>\w+)Reflection/)['shortname'].underscore,
    content: RootStruct.new(node: @association, includes: @next_level_includes, remove_ids: @remove_ids).data
  }.compact
end