Class: DataGuru::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/data_guru/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection_name:, model:, config: default_config(model)) ⇒ Collection

Returns a new instance of Collection.



8
9
10
11
12
# File 'lib/data_guru/collection.rb', line 8

def initialize(collection_name:, model:, config: default_config(model))
  @collection_name = collection_name
  @model = model
  @config = config
end

Instance Attribute Details

#collection_nameObject (readonly)

Returns the value of attribute collection_name.



6
7
8
# File 'lib/data_guru/collection.rb', line 6

def collection_name
  @collection_name
end

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/data_guru/collection.rb', line 6

def config
  @config
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/data_guru/collection.rb', line 6

def model
  @model
end

Instance Method Details

#allObject



14
15
16
# File 'lib/data_guru/collection.rb', line 14

def all
  @all ||= build_models(collection_name)
end

#each(&block) ⇒ Object



18
19
20
# File 'lib/data_guru/collection.rb', line 18

def each(&block)
  all.each(&block)
end