Class: Rails::Schema::Extractor::Mongoid::AssociationReader

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/schema/extractor/mongoid/association_reader.rb

Constant Summary collapse

ASSOCIATION_TYPE_MAP =
{
  "Mongoid::Association::Referenced::HasMany" => "has_many",
  "Mongoid::Association::Referenced::HasOne" => "has_one",
  "Mongoid::Association::Referenced::BelongsTo" => "belongs_to",
  "Mongoid::Association::Referenced::HasAndBelongsToMany" => "has_and_belongs_to_many",
  "Mongoid::Association::Embedded::EmbedsMany" => "embeds_many",
  "Mongoid::Association::Embedded::EmbedsOne" => "embeds_one",
  "Mongoid::Association::Embedded::EmbeddedIn" => "embedded_in"
}.freeze

Instance Method Summary collapse

Instance Method Details

#read(model) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/rails/schema/extractor/mongoid/association_reader.rb', line 18

def read(model)
  model.relations.filter_map do |name, |
    next if skip_association?()

    build_association_data(model, name, )
  end
rescue StandardError => e
  warn "[rails-schema] Could not read Mongoid relations for #{model.name}: #{e.class}: #{e.message}"
  []
end