Class: ActiveRecordDataLoader::Dsl::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_data_loader/dsl/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = ActiveRecordDataLoader.configuration) ⇒ Definition

Returns a new instance of Definition.



8
9
10
11
# File 'lib/active_record_data_loader/dsl/definition.rb', line 8

def initialize(config = ActiveRecordDataLoader.configuration)
  @models = []
  @config = config
end

Instance Attribute Details

#modelsObject (readonly)

Returns the value of attribute models.



6
7
8
# File 'lib/active_record_data_loader/dsl/definition.rb', line 6

def models
  @models
end

Instance Method Details

#model(klass, &block) ⇒ Object



13
14
15
16
17
18
# File 'lib/active_record_data_loader/dsl/definition.rb', line 13

def model(klass, &block)
  t = Model.new(klass: klass, configuration: config)
  block&.call(t)
  models << t
  t
end