baseapi 0.1.10 → 0.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9458a084335b8367f4758d5e98a419d4255d9635
4
- data.tar.gz: 275a2633ec64ce87a21eb077599f9f2bd5ba72b2
3
+ metadata.gz: 936fbd26520a71667904014ba7483ad45e8147bf
4
+ data.tar.gz: 715371435bdfdc327b13eeecd1fd6749c15318fd
5
5
  SHA512:
6
- metadata.gz: c2910253e825b666b784cb6eaa017ff36e1ee75a805fad23284eb8f287bd2b4b185b66fe7db24c0cbb9138eb13ff58623ac6b6188933ed8e13360c1471a11041
7
- data.tar.gz: 200cae2049be21cf6f57ce06a330d16f3ba9771438e0812a1cce4097dae0f20f18fd6c1d31142a1ffd37378972fdd408480eed4d798379d1917adc57f326a19e
6
+ metadata.gz: f369bec23293e8f0714047795914389a42e70179d51030f6e19d6c24a8f6467cf165da8c618a228ef002919ca783a7c9ca65a2fa316e5c6c3610f40511823b46
7
+ data.tar.gz: 602e8694c2d6a6a2cc0bff313e5d643dffe87bc79b6c662381900fb31a413a50e049fcd1371e25635f7100d127317f99253d1fbc7a561e843d65f9f96e88b529
data/README.md CHANGED
@@ -157,6 +157,30 @@ Specify the User belong to a development part company
157
157
 
158
158
  GET /users.json?company[units][name]=development
159
159
 
160
+ Specify it more 20~ (v0.1.11~)
161
+
162
+ GET /users.json?age=>=20
163
+
164
+ Specify it less ~20 (v0.1.11~)
165
+
166
+ GET /users.json?age=<=20
167
+
168
+ Specify between 2015/09/01 ~ 2015/09/31 (v0.1.11~)
169
+
170
+ GET /users.json?created_at[]=>=20150901&created_at[]=<=20150931
171
+
172
+ Multiple conditions is "OR Search" by default
173
+
174
+ Multiple conditions is "AND Search" and must
175
+
176
+ provide a method such as the following to the model in advance
177
+
178
+ class User < ActiveRecord::Base
179
+ def self._where_created_at(models, column, values)
180
+ column_match(models, column, values, operator:'and')
181
+ end
182
+ end
183
+
160
184
  #### action show
161
185
 
162
186
  Get id 1
@@ -119,7 +119,14 @@ module ActiveRecordBaseExtension extend ActiveSupport::Concern
119
119
  # @param String value
120
120
  # @return String operator
121
121
  def getOperator(value, default = '=')
122
- ['NULL', 'EMPTY'].include?(value.gsub('!', '').upcase) ? 'IS' : default
122
+ operator = default
123
+ value = value.sub('!', '')
124
+ if ['NULL', 'EMPTY'].include?(value.upcase)
125
+ operator = 'IS'
126
+ elsif value.length >= 2 and ['<=', '>='].include?(value[0..1])
127
+ operator = value[0..1]
128
+ end
129
+ operator
123
130
  end
124
131
 
125
132
  # slice '!' value
@@ -136,6 +143,8 @@ module ActiveRecordBaseExtension extend ActiveSupport::Concern
136
143
  prefix = getPrefix(original)
137
144
  operator = prefix == 'NOT' ? 'AND' : 'OR'
138
145
  value = "NULL #{operator} #{prefix} #{column} = ''"
146
+ elsif value.length >= 2 and ['<=', '>='].include?(value[0..1])
147
+ value = value.sub('<=', '').sub('>=', '')
139
148
  else
140
149
  value = getNaturalValue(value)
141
150
  wraps.each do |wrap|
@@ -1,3 +1,3 @@
1
1
  module Baseapi
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baseapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moriyuki Arakawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler