lotus-model 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +159 -0
- data/{LICENSE.txt → LICENSE.md} +0 -0
- data/README.md +29 -28
- data/lib/lotus/entity.rb +6 -13
- data/lib/lotus/model/adapters/memory/query.rb +9 -9
- data/lib/lotus/model/adapters/sql/query.rb +9 -9
- data/lib/lotus/model/mapper.rb +3 -3
- data/lib/lotus/model/mapping/coercer.rb +4 -4
- data/lib/lotus/model/mapping/coercions.rb +162 -0
- data/lib/lotus/model/mapping/collection.rb +2 -2
- data/lib/lotus/model/version.rb +1 -1
- data/lib/lotus/repository.rb +9 -9
- data/lotus-model.gemspec +3 -3
- metadata +10 -47
- data/.gitignore +0 -18
- data/.travis.yml +0 -6
- data/.yardopts +0 -5
- data/Gemfile +0 -16
- data/Rakefile +0 -17
- data/test/entity_test.rb +0 -126
- data/test/fixtures.rb +0 -81
- data/test/model/adapters/abstract_test.rb +0 -75
- data/test/model/adapters/implementation_test.rb +0 -22
- data/test/model/adapters/memory/query_test.rb +0 -91
- data/test/model/adapters/memory_adapter_test.rb +0 -1044
- data/test/model/adapters/sql/query_test.rb +0 -121
- data/test/model/adapters/sql_adapter_test.rb +0 -1078
- data/test/model/mapper_test.rb +0 -94
- data/test/model/mapping/coercer_test.rb +0 -27
- data/test/model/mapping/collection_test.rb +0 -82
- data/test/repository_test.rb +0 -283
- data/test/test_helper.rb +0 -30
- data/test/version_test.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d28ccedb8722497c957e6b3faf8c8fe885d2cf
|
4
|
+
data.tar.gz: 5eae2a84ec0ccd7be8dfcd3ea1771f99822b437c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3354751cde9176e5aae2e4686450f514a5a419afd5dc1e2bd8d345ad551e3728b6712311e7ea297bbb082f7b9b100ad7011a9ad386e416d42210dc6c6970d018
|
7
|
+
data.tar.gz: d9fb84225ab7d354f7bd99d3fdcf9c6ad23d7b07f20eeabb68d95e32fa0e937aceb86a1c72287210b402b41e348b6d208a807600cc24964ce22451b19cded59c
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
## v0.1.1
|
2
|
+
### Jun 23, 2014
|
3
|
+
|
4
|
+
99ea094 2014-06-13 **Luca Guidi** Introduced Lotus::Model::Mapping::Coercions in order to decouple from Lotus::Utils::Kernel
|
5
|
+
|
6
|
+
3fa2693 2014-05-10 **Luca Guidi** Support for Ruby 2.1.2
|
7
|
+
|
8
|
+
3682552 2014-04-25 **Peter Suschlik** Iterate over each value using `each_value`
|
9
|
+
|
10
|
+
cce7746 2014-04-24 **Peter Suschlik** Just extend the base class. No need to class_eval
|
11
|
+
|
12
|
+
719e03c 2014-04-24 **Peter Suschlik** Pass list of attributes to `attr_accessor`
|
13
|
+
|
14
|
+
## v0.1.0
|
15
|
+
### Apr 23, 2014
|
16
|
+
|
17
|
+
ec395d8 2014-04-22 **Luca Guidi** Added an accessor to introspect Mapper collections
|
18
|
+
|
19
|
+
96d9d00 2014-04-18 **Luca Guidi** Allow queries to be composed
|
20
|
+
|
21
|
+
a7d64c1 2014-04-18 **Damir Zekic** Don't serialize identity column if it's nil
|
22
|
+
|
23
|
+
8484941 2014-04-17 **Luca Guidi** Fixed Sql::Collection#select for Ruby 2.0.0
|
24
|
+
|
25
|
+
bd9d679 2014-04-17 **Luca Guidi** Allow Sql#Query#order and #desc to accept multiple columns and/or multiple invokations.
|
26
|
+
|
27
|
+
b6a7af8 2014-04-16 **Luca Guidi** Enforce Adapter interface with #command and #query
|
28
|
+
|
29
|
+
3787f33 2014-04-16 **Luca Guidi** Allow Mapper to accept a custom coercer for the database
|
30
|
+
|
31
|
+
893109a 2014-04-15 **Luca Guidi** Ensure that unmapped attributes doens't interfer with initialization of entities
|
32
|
+
|
33
|
+
da37d7a 2014-04-15 **Luca Guidi** Implemented Memory::Query #to_s, #empty? and #any?
|
34
|
+
|
35
|
+
94f0ecb 2014-04-15 **Luca Guidi** Implemented Repository#exclude
|
36
|
+
|
37
|
+
6998328 2014-04-15 **Luca Guidi** Removed unused require
|
38
|
+
|
39
|
+
7211935 2014-04-15 **Luca Guidi** Implemented Sql::Query #to_s, #empty? and #any?
|
40
|
+
|
41
|
+
5e7e0c4 2014-04-15 **Luca Guidi** Implemented Sql::Query#negate!
|
42
|
+
|
43
|
+
5df30c2 2014-04-15 **Luca Guidi** Define top level constant ::Boolean
|
44
|
+
|
45
|
+
a9df2ec 2014-04-15 **Luca Guidi** Load Mapper when the framework is loaded
|
46
|
+
|
47
|
+
de21101 2014-04-15 **Luca Guidi** Extracted Mapping::Collection::REPOSITORY_SUFFIX constant
|
48
|
+
|
49
|
+
b4ed0fe 2014-04-15 **Luca Guidi** Expose Mapper#load! to make Lotus::Model thread safe
|
50
|
+
|
51
|
+
0936848 2014-04-14 **Luca Guidi** Moved UnmappedCollectionError under a separated file
|
52
|
+
|
53
|
+
b6e49ff 2014-04-14 **Luca Guidi** Removed serialization responsibility from Mapper
|
54
|
+
|
55
|
+
9057fbd 2014-04-14 **Luca Guidi** Removed unnecessary conditional in test
|
56
|
+
|
57
|
+
43c462f 2014-04-14 **Luca Guidi** Renamed Lotus::Model::Mapping::Collection#key into #identity
|
58
|
+
|
59
|
+
af59039 2014-04-14 **Luca Guidi** Removed serialization responsibility from Sql::Command
|
60
|
+
|
61
|
+
92101bb 2014-04-14 **Luca Guidi** Removed deserialization responsibility from Sql::Query
|
62
|
+
|
63
|
+
04e9597 2014-04-14 **Luca Guidi** Rewritten Sql::Command, it now works on scoped queries
|
64
|
+
|
65
|
+
eb49746 2014-04-14 **Luca Guidi** Coerce with the right type the primary key for Repository.find
|
66
|
+
|
67
|
+
daf3e04 2014-04-14 **Luca Guidi** Implemented Command for mutation actions such as insert, update, delete. Removed serialization responsibility to the adapter. Removed unused code.
|
68
|
+
|
69
|
+
5ae8b11 2014-04-13 **Luca Guidi** Sql and Memory adapter are now using Query to serve #all, #find, #first, #last
|
70
|
+
|
71
|
+
b0a35c5 2014-04-13 **Luca Guidi** Implemented Query#asc and #desc
|
72
|
+
|
73
|
+
ef2d1fa 2014-04-13 **Luca Guidi** Make querying thread safe for MemoryAdapter
|
74
|
+
|
75
|
+
db7e699 2014-04-12 **Luca Guidi** Implemented Query#select
|
76
|
+
|
77
|
+
2d83581 2014-04-12 **Luca Guidi** Implemented Query#exist?
|
78
|
+
|
79
|
+
13cfde0 2014-04-12 **Luca Guidi** Implemented Query#exclude
|
80
|
+
|
81
|
+
79596de 2014-04-12 **Luca Guidi** Implemented Query#range
|
82
|
+
|
83
|
+
70df238 2014-04-12 **Luca Guidi** Implemented Query#interval
|
84
|
+
|
85
|
+
a0cbb8c 2014-04-12 **Luca Guidi** Implemented Query#min
|
86
|
+
|
87
|
+
41e3d69 2014-04-12 **Luca Guidi** Implemented Query#max
|
88
|
+
|
89
|
+
5577283 2014-04-12 **Luca Guidi** Changed the semantic of Query#average: let return a float if needed, handle strings and nil values
|
90
|
+
|
91
|
+
3e1bddc 2014-04-12 **Luca Guidi** Implemented Query#sum
|
92
|
+
|
93
|
+
97d0fb9 2014-04-12 **Luca Guidi** Implemented Lotus::Model::Adapters::Memory::Query#average
|
94
|
+
|
95
|
+
d7068b5 2014-04-12 **Luca Guidi** Implemented Lotus::Model::Adapters::Sql::Query#average
|
96
|
+
|
97
|
+
21abc27 2014-04-10 **Luca Guidi** Introduced Sql::Query
|
98
|
+
|
99
|
+
7b63b7f 2014-04-10 **Luca Guidi** Implemented Memory::Query#count
|
100
|
+
|
101
|
+
517a89a 2014-04-10 **Luca Guidi** Make the results of Repository queries lazy
|
102
|
+
|
103
|
+
e6a756c 2014-04-10 **Luca Guidi** Renamed adapters with the "Adapter" suffix, in order to keep namespaces free.
|
104
|
+
|
105
|
+
8a076b9 2014-04-10 **Luca Guidi** Implemented Query#or, #limit and #offset
|
106
|
+
|
107
|
+
388957d 2014-04-09 **Luca Guidi** Added tests for SQL adapter and implemented #where, #and and #order for all the adapters
|
108
|
+
|
109
|
+
5a97c12 2014-04-09 **Luca Guidi** Initial design for quering the datasource
|
110
|
+
|
111
|
+
6f804db 2014-04-08 **Luca Guidi** Use Lotus::Utils::Kernel conversions
|
112
|
+
|
113
|
+
4ae6967 2014-04-07 **Luca Guidi** Allow the mapper to specify the primary key of a collection with Lotus::Model::Mapper::Collection#key.
|
114
|
+
|
115
|
+
85def40 2014-04-07 **Luca Guidi** Extracted Lotus::Model::Adapters::Memory::Collection::PrimaryKey
|
116
|
+
|
117
|
+
ff8d6d4 2014-04-07 **Luca Guidi** Lotus::Repository.collection is now configured by the framework internals.
|
118
|
+
|
119
|
+
122e040 2014-04-02 **Luca Guidi** Introduced attributes mapping and (de)serializations policies based on it.
|
120
|
+
|
121
|
+
f925ebc 2014-03-26 **Luca Guidi** Lotus::Entity#id is always the primary key
|
122
|
+
|
123
|
+
0bf8bb5 2014-03-26 **Luca Guidi** Introduced Lotus::Model::Adapters::Sql
|
124
|
+
|
125
|
+
cfbed99 2014-03-26 **Luca Guidi** Lotus::Model::Repository => Lotus::Repository
|
126
|
+
|
127
|
+
3a72d68 2014-03-26 **Luca Guidi** Lotus::Model::Entity => Lotus::Entity
|
128
|
+
|
129
|
+
ed29d2d 2014-03-26 **Luca Guidi** Preload Lotus::Model::Repository
|
130
|
+
|
131
|
+
f1bda7f 2014-03-26 **Luca Guidi** Improved tests and better semantic for Lotus::Model::Repository
|
132
|
+
|
133
|
+
65b8e1a 2014-03-26 **Luca Guidi** Tests and thready safety for Lotus::Model::Adapters::Memory
|
134
|
+
|
135
|
+
63d9fc5 2014-03-26 **Luca Guidi** When generate Entity#initialize use class attribute 'attributes', instead of the homonym argument
|
136
|
+
|
137
|
+
442987d 2014-02-17 **Luca Guidi** Lotus::Model::Repository.find raises a Lotus::Model::RecordNotFound exception if it can't find a record, associated with the given ID
|
138
|
+
|
139
|
+
c2b94e0 2014-02-15 **Luca Guidi** Ensure memory adapted is able to find a record for a string id
|
140
|
+
|
141
|
+
b258ea0 2014-02-07 **Luca Guidi** Make Repository to work with entities
|
142
|
+
|
143
|
+
0371b41 2014-02-05 **Luca Guidi** Implemented Entity
|
144
|
+
|
145
|
+
9d2bfe3 2014-02-05 **Luca Guidi** Renamed "object" in "entity" in method signatures. Repositories and adapters work on objects that are aware of the identity's concept.
|
146
|
+
|
147
|
+
be0e4e0 2014-02-05 **Luca Guidi** Extracted Abstract adapter and made Memory to inherit from it
|
148
|
+
|
149
|
+
3ca28af 2014-02-05 **Luca Guidi** Let Repository to delegate operations to the current adapter
|
150
|
+
|
151
|
+
3318bd1 2014-02-05 **Luca Guidi** Made Repository methods to accept one object instead of a collection
|
152
|
+
|
153
|
+
baf378a 2014-02-05 **Luca Guidi** Implemented Repository.delete
|
154
|
+
|
155
|
+
1b8c0a0 2014-02-05 **Luca Guidi** Implemented Repository.persist, .create and .update
|
156
|
+
|
157
|
+
c6bde87 2014-02-05 **Luca Guidi** Implemented Repository.find
|
158
|
+
|
159
|
+
a45248f 2014-02-05 **Luca Guidi** Initial mess
|
data/{LICENSE.txt → LICENSE.md}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -3,26 +3,26 @@
|
|
3
3
|
A persistence framework for [Lotus](http://lotusrb.org).
|
4
4
|
|
5
5
|
It delivers a convenient public API to execute queries and commands against a database.
|
6
|
-
The architecture
|
6
|
+
The architecture eases keeping the business logic (entities) separated from details such as persistence or validations.
|
7
7
|
|
8
8
|
It implements the following concepts:
|
9
9
|
|
10
10
|
* [Entity](#entities) - An object defined by its identity.
|
11
11
|
* [Repository](#repositories) - An object that mediates between the entities and the persistence layer.
|
12
|
-
* [Data Mapper](#
|
13
|
-
* [Adapter](#
|
14
|
-
* [Query](#
|
12
|
+
* [Data Mapper](#data-mapper) - A persistence mapper that keep entities independent from database details.
|
13
|
+
* [Adapter](#adapter) – A database adapter.
|
14
|
+
* [Query](#query) - An object that represents a database query.
|
15
15
|
|
16
|
-
Like all the other Lotus
|
16
|
+
Like all the other Lotus components, it can be used as a standalone framework or within a full Lotus application.
|
17
17
|
|
18
18
|
## Status
|
19
19
|
|
20
|
-
[](http://badge.fury.io/rb/lotus-model)
|
21
|
+
[](http://travis-ci.org/lotus/model?branch=master)
|
22
|
+
[](https://coveralls.io/r/lotus/model)
|
23
|
+
[](https://codeclimate.com/github/lotus/model)
|
24
|
+
[](https://gemnasium.com/lotus/model)
|
25
|
+
[](http://inch-ci.org/github/lotus/model)
|
26
26
|
|
27
27
|
## Contact
|
28
28
|
|
@@ -35,7 +35,7 @@ Like all the other Lotus compontents, it can be used as a standalone framework o
|
|
35
35
|
|
36
36
|
## Rubies
|
37
37
|
|
38
|
-
__Lotus::
|
38
|
+
__Lotus::Model__ supports Ruby (MRI) 2+
|
39
39
|
|
40
40
|
## Installation
|
41
41
|
|
@@ -58,7 +58,7 @@ Or install it yourself as:
|
|
58
58
|
An object that is defined by its identity.
|
59
59
|
|
60
60
|
An entity is the core of an application, where the part of the domain logic is implemented.
|
61
|
-
It's a small, cohesive object that
|
61
|
+
It's a small, cohesive object that expresses coherent and meaningful behaviors.
|
62
62
|
|
63
63
|
It deals with one and only one responsibility that is pertinent to the
|
64
64
|
domain of the application, without caring about details such as persistence
|
@@ -101,18 +101,18 @@ rest of the framework is able to accept any object that implements the interface
|
|
101
101
|
|
102
102
|
### Repositories
|
103
103
|
|
104
|
-
|
104
|
+
An object that mediates between entities and the persistence layer.
|
105
105
|
It offers a standardized API to query and execute commands on a database.
|
106
106
|
|
107
|
-
A repository is **storage
|
107
|
+
A repository is **storage independent**, all the queries and commands are
|
108
108
|
delegated to the current adapter.
|
109
109
|
|
110
110
|
This architecture has several advantages:
|
111
111
|
|
112
|
-
* Applications
|
112
|
+
* Applications depend on a standard API, instead of low level details
|
113
113
|
(Dependency Inversion principle)
|
114
114
|
|
115
|
-
* Applications
|
115
|
+
* Applications depend on a stable API, that doesn't change if the
|
116
116
|
storage changes
|
117
117
|
|
118
118
|
* Developers can postpone storage decisions
|
@@ -125,9 +125,10 @@ When a class includes `Lotus::Repository`, it will receive the following interfa
|
|
125
125
|
|
126
126
|
* `.persist(entity)` – Create or update an entity
|
127
127
|
* `.create(entity)` – Create a record for the given entity
|
128
|
-
* `.update(entity)` – Update the record
|
129
|
-
* `.delete(entity)` – Delete the record
|
128
|
+
* `.update(entity)` – Update the record corresponding to the given entity
|
129
|
+
* `.delete(entity)` – Delete the record corresponding to the given entity
|
130
130
|
* `.all` - Fetch all the entities from the collection
|
131
|
+
* `.find` - Fetch an entity from the collection by its ID
|
131
132
|
* `.first` - Fetch the first entity from the collection
|
132
133
|
* `.last` - Fetch the last entity from the collection
|
133
134
|
* `.clear` - Delete all the records from the collection
|
@@ -182,11 +183,11 @@ This is a **huge improvement**, because:
|
|
182
183
|
|
183
184
|
* It expresses a clear intent.
|
184
185
|
|
185
|
-
* The caller can be easily tested in isolation. It's just a matter of
|
186
|
+
* The caller can be easily tested in isolation. It's just a matter of stubbing this method.
|
186
187
|
|
187
188
|
* If we change the storage, the callers aren't affected.
|
188
189
|
|
189
|
-
Here an extended example of a repository that uses the SQL adapter.
|
190
|
+
Here is an extended example of a repository that uses the SQL adapter.
|
190
191
|
|
191
192
|
```ruby
|
192
193
|
class ArticleRepository
|
@@ -230,8 +231,8 @@ end
|
|
230
231
|
|
231
232
|
### Data Mapper
|
232
233
|
|
233
|
-
A persistence mapper that
|
234
|
-
It
|
234
|
+
A persistence mapper that keeps entities independent from database details.
|
235
|
+
It is database independent, it can work with SQL, document, and even with key/value stores.
|
235
236
|
|
236
237
|
The role of a data mapper is to translate database columns into the corresponding attribute of an entity.
|
237
238
|
|
@@ -250,7 +251,7 @@ end
|
|
250
251
|
```
|
251
252
|
|
252
253
|
For simplicity sake, imagine that the mapper above is used with a SQL database.
|
253
|
-
We use `#collection` to indicate the table that we want to map, `#entity` to indicate the class that we want to associate.
|
254
|
+
We use `#collection` to indicate the name of the table that we want to map, `#entity` to indicate the class that we want to associate.
|
254
255
|
In the end, each `#attribute` call, is to associate the column with a Ruby type.
|
255
256
|
|
256
257
|
For advanced mapping and legacy databases, please have a look at the API doc.
|
@@ -263,7 +264,7 @@ An adapter is a concrete implementation of persistence logic for a specific data
|
|
263
264
|
* SqlAdapter
|
264
265
|
* MemoryAdapter
|
265
266
|
|
266
|
-
An adapter can be associated
|
267
|
+
An adapter can be associated with one or multiple repositories.
|
267
268
|
|
268
269
|
```ruby
|
269
270
|
require 'pg'
|
@@ -280,18 +281,18 @@ PersonRepository.adapter = adapter
|
|
280
281
|
ArticleRepository.adapter = adapter
|
281
282
|
```
|
282
283
|
|
283
|
-
In the example above, we reuse the
|
284
|
+
In the example above, we reuse the adapter because the target tables (`people` and `articles`) are defined in the same database.
|
284
285
|
**As rule of thumb, one adapter instance per database.**
|
285
286
|
|
286
287
|
### Query
|
287
288
|
|
288
289
|
An object that implements an interface for quering the database.
|
289
290
|
This interface may vary, according to the adapter's specifications.
|
290
|
-
Think of an adapter for Redis, it will probably employ different strategies to filter records
|
291
|
+
Think of an adapter for Redis, it will probably employ different strategies to filter records than an SQL query object.
|
291
292
|
|
292
293
|
### Conventions
|
293
294
|
|
294
|
-
* A repository must be named after an entity, by
|
295
|
+
* A repository must be named after an entity, by appending `"Repository"` to the entity class name (eg. `Article` => `ArticleRepository`).
|
295
296
|
|
296
297
|
### Thread safety
|
297
298
|
|
data/lib/lotus/entity.rb
CHANGED
@@ -6,7 +6,7 @@ module Lotus
|
|
6
6
|
#
|
7
7
|
# An entity is the core of an application, where the part of the domain
|
8
8
|
# logic is implemented. It's a small, cohesive object that express coherent
|
9
|
-
# and
|
9
|
+
# and meaningful behaviors.
|
10
10
|
#
|
11
11
|
# It deals with one and only one responsibility that is pertinent to the
|
12
12
|
# domain of the application, without caring about details such as persistence
|
@@ -24,15 +24,14 @@ module Lotus
|
|
24
24
|
# self.attributes = :name, :age
|
25
25
|
# end
|
26
26
|
#
|
27
|
-
# When a class includes `Lotus::Entity`
|
27
|
+
# When a class includes `Lotus::Entity` the `.attributes=` method is exposed.
|
28
|
+
# By then calling the `.attributes=` class method, the following methods are
|
29
|
+
# added:
|
28
30
|
#
|
29
31
|
# * #id
|
30
32
|
# * #id=
|
31
33
|
# * #initialize(attributes = {})
|
32
34
|
#
|
33
|
-
# Also, the usage of `.attributes=` defines accessors for the given attribute
|
34
|
-
# names.
|
35
|
-
#
|
36
35
|
# If we expand the code above in pure Ruby, it would be:
|
37
36
|
#
|
38
37
|
# @example Pure Ruby
|
@@ -72,9 +71,7 @@ module Lotus
|
|
72
71
|
# include Lotus::Entity
|
73
72
|
# end
|
74
73
|
def self.included(base)
|
75
|
-
base.
|
76
|
-
extend ClassMethods
|
77
|
-
end
|
74
|
+
base.extend ClassMethods
|
78
75
|
end
|
79
76
|
|
80
77
|
module ClassMethods
|
@@ -113,11 +110,7 @@ module Lotus
|
|
113
110
|
end
|
114
111
|
}
|
115
112
|
|
116
|
-
|
117
|
-
class_eval do
|
118
|
-
attr_accessor attr
|
119
|
-
end
|
120
|
-
end
|
113
|
+
attr_accessor *@attributes
|
121
114
|
end
|
122
115
|
|
123
116
|
def attributes
|
@@ -129,12 +129,12 @@ module Lotus
|
|
129
129
|
#
|
130
130
|
# @example Range
|
131
131
|
#
|
132
|
-
# query.
|
132
|
+
# query.exclude(year: 1900..1982)
|
133
133
|
#
|
134
134
|
# @example Multiple conditions
|
135
135
|
#
|
136
|
-
# query.
|
137
|
-
# .
|
136
|
+
# query.exclude(language: 'java')
|
137
|
+
# .exclude(company: 'enterprise')
|
138
138
|
def exclude(condition)
|
139
139
|
column, value = _expand_condition(condition)
|
140
140
|
conditions.push(Proc.new{ reject! {|r| r.fetch(column) == value} })
|
@@ -261,7 +261,7 @@ module Lotus
|
|
261
261
|
|
262
262
|
# Returns the sum of the values for the given column.
|
263
263
|
#
|
264
|
-
# @param column [Symbol] the
|
264
|
+
# @param column [Symbol] the column name
|
265
265
|
#
|
266
266
|
# @return [Numeric]
|
267
267
|
#
|
@@ -286,7 +286,7 @@ module Lotus
|
|
286
286
|
|
287
287
|
# Returns the average of the values for the given column.
|
288
288
|
#
|
289
|
-
# @param column [Symbol] the
|
289
|
+
# @param column [Symbol] the column name
|
290
290
|
#
|
291
291
|
# @return [Numeric]
|
292
292
|
#
|
@@ -305,7 +305,7 @@ module Lotus
|
|
305
305
|
|
306
306
|
# Returns the maximum value for the given column.
|
307
307
|
#
|
308
|
-
# @param column [Symbol] the
|
308
|
+
# @param column [Symbol] the column name
|
309
309
|
#
|
310
310
|
# @return result
|
311
311
|
#
|
@@ -320,7 +320,7 @@ module Lotus
|
|
320
320
|
|
321
321
|
# Returns the minimum value for the given column.
|
322
322
|
#
|
323
|
-
# @param column [Symbol] the
|
323
|
+
# @param column [Symbol] the column name
|
324
324
|
#
|
325
325
|
# @return result
|
326
326
|
#
|
@@ -335,7 +335,7 @@ module Lotus
|
|
335
335
|
|
336
336
|
# Returns the difference between the MAX and MIN for the given column.
|
337
337
|
#
|
338
|
-
# @param column [Symbol] the
|
338
|
+
# @param column [Symbol] the column name
|
339
339
|
#
|
340
340
|
# @return [Numeric]
|
341
341
|
#
|
@@ -355,7 +355,7 @@ module Lotus
|
|
355
355
|
# Returns a range of values between the MAX and the MIN for the given
|
356
356
|
# column.
|
357
357
|
#
|
358
|
-
# @param column [Symbol] the
|
358
|
+
# @param column [Symbol] the column name
|
359
359
|
#
|
360
360
|
# @return [Range]
|
361
361
|
#
|
@@ -180,14 +180,14 @@ module Lotus
|
|
180
180
|
#
|
181
181
|
# @example Range
|
182
182
|
#
|
183
|
-
# query.
|
183
|
+
# query.exclude(year: 1900..1982)
|
184
184
|
#
|
185
185
|
# # => SELECT * FROM `people` WHERE ((`year` < 1900) AND (`year` > 1982))
|
186
186
|
#
|
187
187
|
# @example Multiple conditions
|
188
188
|
#
|
189
|
-
# query.
|
190
|
-
# .
|
189
|
+
# query.exclude(language: 'java')
|
190
|
+
# .exclude(company: 'enterprise')
|
191
191
|
#
|
192
192
|
# # => SELECT * FROM `projects` WHERE (`language` != 'java') AND (`company` != 'enterprise')
|
193
193
|
def exclude(condition)
|
@@ -338,7 +338,7 @@ module Lotus
|
|
338
338
|
|
339
339
|
# Returns the sum of the values for the given column.
|
340
340
|
#
|
341
|
-
# @param column [Symbol] the
|
341
|
+
# @param column [Symbol] the column name
|
342
342
|
#
|
343
343
|
# @return [Numeric]
|
344
344
|
#
|
@@ -355,7 +355,7 @@ module Lotus
|
|
355
355
|
|
356
356
|
# Returns the average of the values for the given column.
|
357
357
|
#
|
358
|
-
# @param column [Symbol] the
|
358
|
+
# @param column [Symbol] the column name
|
359
359
|
#
|
360
360
|
# @return [Numeric]
|
361
361
|
#
|
@@ -374,7 +374,7 @@ module Lotus
|
|
374
374
|
|
375
375
|
# Returns the maximum value for the given column.
|
376
376
|
#
|
377
|
-
# @param column [Symbol] the
|
377
|
+
# @param column [Symbol] the column name
|
378
378
|
#
|
379
379
|
# @return result
|
380
380
|
#
|
@@ -397,7 +397,7 @@ module Lotus
|
|
397
397
|
|
398
398
|
# Returns the minimum value for the given column.
|
399
399
|
#
|
400
|
-
# @param column [Symbol] the
|
400
|
+
# @param column [Symbol] the column name
|
401
401
|
#
|
402
402
|
# @return result
|
403
403
|
#
|
@@ -420,7 +420,7 @@ module Lotus
|
|
420
420
|
|
421
421
|
# Returns the difference between the MAX and MIN for the given column.
|
422
422
|
#
|
423
|
-
# @param column [Symbol] the
|
423
|
+
# @param column [Symbol] the column name
|
424
424
|
#
|
425
425
|
# @return [Numeric]
|
426
426
|
#
|
@@ -441,7 +441,7 @@ module Lotus
|
|
441
441
|
# Returns a range of values between the MAX and the MIN for the given
|
442
442
|
# column.
|
443
443
|
#
|
444
|
-
# @param column [Symbol] the
|
444
|
+
# @param column [Symbol] the column name
|
445
445
|
#
|
446
446
|
# @return [Range]
|
447
447
|
#
|