pattern_query_helper 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pattern_query_helper.rb +8 -13
- data/lib/pattern_query_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5933735e1e09a3803b1a896b909bcfac03df72ef
|
4
|
+
data.tar.gz: 6a7b84868229e6faba1a39e3751fb3f562cc8098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f92ea4b1daa987c102a23aff0125941a37255e57ba2c773588466c9ed68c520176bcdb1642dbb25c1ee1506b870e66da8159eef455d576f4985f5a0839cdba1a
|
7
|
+
data.tar.gz: d9ee2ebcd3e3008fe1212ba3838835a4158468ef6e534821cd60d951c7ba8b348873d2a87f5b7c01811fecf3e80aefcce4a27a079f9b41c8cc2fc40bc4eaf59f
|
data/Gemfile.lock
CHANGED
data/lib/pattern_query_helper.rb
CHANGED
@@ -6,28 +6,23 @@ require "pattern_query_helper/sorting"
|
|
6
6
|
require "pattern_query_helper/sql"
|
7
7
|
|
8
8
|
module PatternQueryHelper
|
9
|
-
PAGINATED_QUERY = "paginated"
|
10
|
-
SINGLE_RECORD_QUERY = "single_record"
|
11
|
-
COMPLETE_QUERY = "all"
|
12
9
|
|
13
|
-
def self.run_sql_query(model, query, query_params, query_helpers,
|
14
|
-
|
15
|
-
when "single_record"
|
10
|
+
def self.run_sql_query(model, query, query_params, query_helpers, single_record=false)
|
11
|
+
if single_record
|
16
12
|
single_record_sql_query(model, query, query_params, query_helpers)
|
17
|
-
|
13
|
+
elsif query_helpers[:per_page] || query_helpers[:page]
|
18
14
|
paginated_sql_query(model, query, query_params, query_helpers)
|
19
|
-
|
15
|
+
else
|
20
16
|
sql_query(model, query, query_params, query_helpers)
|
21
17
|
end
|
22
18
|
end
|
23
19
|
|
24
|
-
def self.run_active_record_query(active_record_call, query_helpers,
|
25
|
-
|
26
|
-
when "single_record"
|
20
|
+
def self.run_active_record_query(active_record_call, query_helpers, single_record=false)
|
21
|
+
if single_record
|
27
22
|
single_record_active_record_query(active_record_call, query_helpers)
|
28
|
-
|
23
|
+
elsif query_helpers[:per_page] || query_helpers[:page]
|
29
24
|
paginated_active_record_query(active_record_call, query_helpers)
|
30
|
-
|
25
|
+
else
|
31
26
|
active_record_query(active_record_call, query_helpers)
|
32
27
|
end
|
33
28
|
end
|