Class: PruneAr::BelongsToAssociationGatherer

Inherits:
Object
  • Object
show all
Defined in:
lib/prune_ar/belongs_to_association_gatherer.rb

Overview

Given ActiveRecord models, produces BelongsToAssociation objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(models, connection: ActiveRecord::Base.connection, logger: Logger.new(STDOUT).tap { |l| l.level = Logger::WARN }) ⇒ BelongsToAssociationGatherer

Returns a new instance of BelongsToAssociationGatherer.



12
13
14
15
16
17
18
19
20
# File 'lib/prune_ar/belongs_to_association_gatherer.rb', line 12

def initialize(
  models,
  connection: ActiveRecord::Base.connection,
  logger: Logger.new(STDOUT).tap { |l| l.level = Logger::WARN }
)
  @models = models
  @connection = connection
  @logger = logger
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



10
11
12
# File 'lib/prune_ar/belongs_to_association_gatherer.rb', line 10

def connection
  @connection
end

#loggerObject (readonly)

Returns the value of attribute logger.



10
11
12
# File 'lib/prune_ar/belongs_to_association_gatherer.rb', line 10

def logger
  @logger
end

#modelsObject (readonly)

Returns the value of attribute models.



10
11
12
# File 'lib/prune_ar/belongs_to_association_gatherer.rb', line 10

def models
  @models
end

Instance Method Details

#associationsObject



22
23
24
# File 'lib/prune_ar/belongs_to_association_gatherer.rb', line 22

def associations
  @associations ||= gather_belongs_to_for_models
end