Class: Lotus::Model::Adapters::Sql::Collection Private
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Lotus::Model::Adapters::Sql::Collection
- Defined in:
- lib/lotus/model/adapters/sql/collection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Maps a SQL database table and perfoms manipulations on it.
Instance Method Summary collapse
-
#exclude(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
private
Filters the current scope with an ‘exclude` directive.
-
#group(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
private
Filters the current scope with a ‘group` directive.
-
#identity ⇒ Symbol
private
Name of the identity column in database.
-
#initialize(dataset, mapped_collection) ⇒ Lotus::Model::Adapters::Sql::Collection
constructor
private
Initialize a collection.
-
#insert(entity) ⇒ Object
private
Creates a record for the given entity and assigns an id.
-
#join_table(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
private
Use join table for current scope.
-
#limit(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
private
Filters the current scope with a ‘limit` directive.
-
#offset(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
private
Filters the current scope with an ‘offset` directive.
-
#or(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
private
Filters the current scope with an ‘or` directive.
-
#order(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
private
Filters the current scope with an ‘order` directive.
-
#order_more(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
private
Filters the current scope with an ‘order` directive.
- #select(*args) ⇒ Object private
-
#select_all ⇒ Lotus::Model::Adapters::Sql::Collection
private
Select all attributes for current scope.
-
#table_name ⇒ String
private
Return table name mapped collection.
-
#to_a ⇒ Array
private
Resolves self by fetching the records from the database and translating them into entities.
-
#update(entity) ⇒ Object
private
Updates the record corresponding to the given entity.
-
#where(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
private
Filters the current scope with a ‘where` directive.
Constructor Details
#initialize(dataset, mapped_collection) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a collection
27 28 29 30 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 27 def initialize(dataset, mapped_collection) super(dataset) @mapped_collection = mapped_collection end |
Instance Method Details
#exclude(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the current scope with an ‘exclude` directive.
43 44 45 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 43 def exclude(*args) Collection.new(super, @mapped_collection) end |
#group(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the current scope with a ‘group` directive.
172 173 174 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 172 def group(*args) Collection.new(super, @mapped_collection) end |
#identity ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Name of the identity column in database
259 260 261 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 259 def identity @mapped_collection.identity end |
#insert(entity) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a record for the given entity and assigns an id.
57 58 59 60 61 62 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 57 def insert(entity) serialized_entity = _serialize(entity) serialized_entity[identity] = super(serialized_entity) _deserialize(serialized_entity) end |
#join_table(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use join table for current scope
239 240 241 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 239 def join_table(*args) Collection.new(super, @mapped_collection) end |
#limit(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the current scope with a ‘limit` directive.
75 76 77 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 75 def limit(*args) Collection.new(super, @mapped_collection) end |
#offset(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the current scope with an ‘offset` directive.
90 91 92 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 90 def offset(*args) Collection.new(super, @mapped_collection) end |
#or(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the current scope with an ‘or` directive.
105 106 107 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 105 def or(*args) Collection.new(super, @mapped_collection) end |
#order(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the current scope with an ‘order` directive.
120 121 122 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 120 def order(*args) Collection.new(super, @mapped_collection) end |
#order_more(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the current scope with an ‘order` directive.
135 136 137 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 135 def order_more(*args) Collection.new(super, @mapped_collection) end |
#select(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
151 152 153 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 151 def select(*args) Collection.new(super, @mapped_collection) end |
#select_all ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Select all attributes for current scope
226 227 228 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 226 def select_all Collection.new(super(table_name), @mapped_collection) end |
#table_name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return table name mapped collection
249 250 251 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 249 def table_name @mapped_collection.name end |
#to_a ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Resolves self by fetching the records from the database and translating them into entities.
213 214 215 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 213 def to_a @mapped_collection.deserialize(self) end |
#update(entity) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Updates the record corresponding to the given entity.
199 200 201 202 203 204 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 199 def update(entity) serialized_entity = _serialize(entity) super(serialized_entity) _deserialize(serialized_entity) end |
#where(*args) ⇒ Lotus::Model::Adapters::Sql::Collection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the current scope with a ‘where` directive.
187 188 189 |
# File 'lib/lotus/model/adapters/sql/collection.rb', line 187 def where(*args) Collection.new(super, @mapped_collection) end |