Class: DataGuru::Collection
- Inherits:
-
Object
- Object
- DataGuru::Collection
- Includes:
- Enumerable
- Defined in:
- lib/data_guru/collection.rb
Instance Attribute Summary collapse
-
#collection_name ⇒ Object
readonly
Returns the value of attribute collection_name.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #all ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(collection_name:, model:, config: default_config(model)) ⇒ Collection
constructor
A new instance of Collection.
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_name ⇒ Object (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 |
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/data_guru/collection.rb', line 6 def config @config end |
#model ⇒ Object (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
#all ⇒ Object
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 |