active_house 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_house/chainable.rb +6 -2
- data/lib/active_house/collectable.rb +1 -0
- data/lib/active_house/limitable.rb +27 -0
- data/lib/active_house/querying.rb +1 -1
- data/lib/active_house/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85e74ee14ef20d87860ffb175ba8adeef0488777
|
4
|
+
data.tar.gz: 226c0ae19eb0e1c451ac7bcbcfec035bbd602f16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa2e80513b87275dd3996c09f6c6e63c7392fa0ab930468f1ec7fc08ae389b71d9be993cff385d1dcb6b5d98f056115dedbf1c0079164fe55dd807f1d0f09842
|
7
|
+
data.tar.gz: 35c22b8dc84e426b967a10169aa707979e3ed6a5ffb472c25c6092f4dccaadd384facc4c09de719e8e9fadafe29bfd3da9c3c7e8d458a06f571045497420d8ce
|
@@ -3,6 +3,7 @@ require_relative 'fromable'
|
|
3
3
|
require_relative 'whereable'
|
4
4
|
require_relative 'orderable'
|
5
5
|
require_relative 'groupable'
|
6
|
+
require_relative 'limitable'
|
6
7
|
require 'active_support/concern'
|
7
8
|
|
8
9
|
module ActiveHouse
|
@@ -14,6 +15,7 @@ module ActiveHouse
|
|
14
15
|
include ActiveHouse::Whereable
|
15
16
|
include ActiveHouse::Orderable
|
16
17
|
include ActiveHouse::Groupable
|
18
|
+
include ActiveHouse::Limitable
|
17
19
|
|
18
20
|
included do
|
19
21
|
protected
|
@@ -34,7 +36,8 @@ module ActiveHouse
|
|
34
36
|
build_from_query_part,
|
35
37
|
build_where_query_part,
|
36
38
|
build_group_by_query_part,
|
37
|
-
build_order_by_query_part
|
39
|
+
build_order_by_query_part,
|
40
|
+
build_limit_query_part
|
38
41
|
]
|
39
42
|
end
|
40
43
|
|
@@ -86,7 +89,8 @@ module ActiveHouse
|
|
86
89
|
select: :fields,
|
87
90
|
where: :conditions,
|
88
91
|
group_by: :grouping,
|
89
|
-
order_by: :ordering
|
92
|
+
order_by: :ordering,
|
93
|
+
limit: :limit
|
90
94
|
}
|
91
95
|
end
|
92
96
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActiveHouse
|
2
|
+
module Limitable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
private
|
7
|
+
|
8
|
+
def build_limit_query_part
|
9
|
+
return if @limit.empty?
|
10
|
+
if @limit[1]
|
11
|
+
"LIMIT #{@limit[0]}, #{@limit[1]}"
|
12
|
+
else
|
13
|
+
"LIMIT #{@limit[0]}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(*)
|
19
|
+
@limit = []
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def limit(limit_value, offset_value = nil)
|
24
|
+
chain_query limit: (@limit + [limit_value, offset_value]).uniq
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/active_house/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_house
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Talakevich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/active_house/error.rb
|
123
123
|
- lib/active_house/fromable.rb
|
124
124
|
- lib/active_house/groupable.rb
|
125
|
+
- lib/active_house/limitable.rb
|
125
126
|
- lib/active_house/logger.rb
|
126
127
|
- lib/active_house/model.rb
|
127
128
|
- lib/active_house/modeling.rb
|