api_helper 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api_helper/filterable.rb +15 -7
- data/lib/api_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeda154cc88246fbd37bbce92133f4e73feee7a7
|
4
|
+
data.tar.gz: 403c2eb669b8b1ba866f4cec3875f44bf35528ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55d8d8cc853e75cf8d75c2fc45523a35d773daffbf289e5df47d016b2e95378a05801c2a909d78687195ade2787253d2b8501ef852ed441475bed783438b3d51
|
7
|
+
data.tar.gz: c15c43fe4804b574b458ebeba1f8e2c55865cee75d6bedd42e53c0c103d189813f1c382aba5bc5c314e011accf84f91da24f27bff9fd6ce631b8663c2b64d8d8
|
@@ -91,6 +91,14 @@ module APIHelper::Filterable
|
|
91
91
|
|
92
92
|
# if a function is used
|
93
93
|
if func = condition.match(/(?<function>[^\(\)]+)\((?<param>.*)\)/)
|
94
|
+
|
95
|
+
db_column_name = begin
|
96
|
+
raise if ActiveRecord::Base.configurations[Rails.env]['adapter'] != 'mysql2'
|
97
|
+
"`#{resource.table_name}`.`#{field}`"
|
98
|
+
rescue
|
99
|
+
"\"#{resource.table_name}\".\"#{field}\""
|
100
|
+
end
|
101
|
+
|
94
102
|
case func[:function]
|
95
103
|
when 'not'
|
96
104
|
values = func[:param].split(',')
|
@@ -99,38 +107,38 @@ module APIHelper::Filterable
|
|
99
107
|
|
100
108
|
when 'greater_then'
|
101
109
|
resource = resource
|
102
|
-
.where("
|
110
|
+
.where("#{db_column_name} > ?",
|
103
111
|
func[:param])
|
104
112
|
|
105
113
|
when 'less_then'
|
106
114
|
resource = resource
|
107
|
-
.where("
|
115
|
+
.where("#{db_column_name} < ?",
|
108
116
|
func[:param])
|
109
117
|
|
110
118
|
when 'greater_then_or_equal'
|
111
119
|
resource = resource
|
112
|
-
.where("
|
120
|
+
.where("#{db_column_name} >= ?",
|
113
121
|
func[:param])
|
114
122
|
|
115
123
|
when 'less_then_or_equal'
|
116
124
|
resource = resource
|
117
|
-
.where("
|
125
|
+
.where("#{db_column_name} <= ?",
|
118
126
|
func[:param])
|
119
127
|
|
120
128
|
when 'between'
|
121
129
|
param = func[:param].split(',')
|
122
130
|
resource = resource
|
123
|
-
.where("
|
131
|
+
.where("#{db_column_name} BETWEEN ? AND ?",
|
124
132
|
param.first, param.last)
|
125
133
|
|
126
134
|
when 'like'
|
127
135
|
resource = resource
|
128
|
-
.where("
|
136
|
+
.where("#{db_column_name} LIKE ?",
|
129
137
|
func[:param])
|
130
138
|
|
131
139
|
when 'contains'
|
132
140
|
resource = resource
|
133
|
-
.where("
|
141
|
+
.where("#{db_column_name} LIKE ?",
|
134
142
|
"%#{func[:param]}%")
|
135
143
|
|
136
144
|
when 'null'
|
data/lib/api_helper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|