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_data:, config: default_config(model, config_data)) ⇒ Collection

Returns a new instance of Collection.



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

def initialize(collection_name:, model:, config_data:, config: default_config(model, config_data))
  @collection_name = collection_name
  @model = model
  @config = config
  @config_data = config_data
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

#config_dataObject (readonly)

Returns the value of attribute config_data.



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

def config_data
  @config_data
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



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

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

#each(&block) ⇒ Object



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

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