baseapi 0.1.11 → 0.1.12

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: 936fbd26520a71667904014ba7483ad45e8147bf
4
- data.tar.gz: 715371435bdfdc327b13eeecd1fd6749c15318fd
3
+ metadata.gz: f3e73410c8406195ecee9cafea68fb5e51af7002
4
+ data.tar.gz: f42abb494021317b75fcc3fdb59f56665eb93a0c
5
5
  SHA512:
6
- metadata.gz: f369bec23293e8f0714047795914389a42e70179d51030f6e19d6c24a8f6467cf165da8c618a228ef002919ca783a7c9ca65a2fa316e5c6c3610f40511823b46
7
- data.tar.gz: 602e8694c2d6a6a2cc0bff313e5d643dffe87bc79b6c662381900fb31a413a50e049fcd1371e25635f7100d127317f99253d1fbc7a561e843d65f9f96e88b529
6
+ metadata.gz: 94f9e21eec63f75e68802a9e7b881ece8925d639c58068289a98e327c4b174061f9e5c3e4e0deaae158163fca87dc66914ac421f758c7ccc36b2ab1e5941c23a
7
+ data.tar.gz: f279474c03b69be2619384c31cda734dd836a9e5171acbdf34f443d3c2e2c5f17638d9adede9265e6006e5ecb9f52b4510f71292a7c7612642c3d2639e7780c5
data/README.md CHANGED
@@ -157,15 +157,15 @@ 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~)
160
+ Specify it more 20~ (v0.1.12~)
161
161
 
162
162
  GET /users.json?age=>=20
163
163
 
164
- Specify it less ~20 (v0.1.11~)
164
+ Specify it less ~20 (v0.1.12~)
165
165
 
166
166
  GET /users.json?age=<=20
167
167
 
168
- Specify between 2015/09/01 ~ 2015/09/31 (v0.1.11~)
168
+ Specify between 2015/09/01 ~ 2015/09/31 (v0.1.12~)
169
169
 
170
170
  GET /users.json?created_at[]=>=20150901&created_at[]=<=20150931
171
171
 
@@ -281,7 +281,7 @@ company belongs_to search
281
281
  end
282
282
  end
283
283
 
284
- If there are multiple related belongs_to
284
+ If there are multiple related belongs_to (v0.1.12~)
285
285
 
286
286
  def self._belongs_to_company_units_...(models, table, hash)
287
287
 
@@ -303,7 +303,7 @@ users has_many search
303
303
  end
304
304
  end
305
305
 
306
- If there are multiple related has_many
306
+ If there are multiple related has_many (v0.1.12~)
307
307
 
308
308
  def self._has_many_users_families_...(models, table, hash)
309
309
 
@@ -16,22 +16,24 @@ module ActiveRecordRelationExtension
16
16
  models = self.model.send(function_name, models, key, values)
17
17
  # belongs_to, has_many search
18
18
  else
19
- relationSearch = -> (models, currentModel, key, value, joins = []) {
19
+ relationSearch = -> (models, currentModel, key, value, prifix = '', joins = []) {
20
+ joins.push key
20
21
  associations = currentModel.get_associations()
21
22
  associations.keys.each do |association|
22
23
  if currentModel.column_names.include?(key)
23
24
  # call function
24
- function_name = self.model.methods.include?("_#{association}_#{joins.join('_')}".to_sym) ? "_#{association}_#{joins.join('_')}" : "_#{association}"
25
+ function_name = self.model.methods.include?("_#{prifix}_#{joins.join('_')}".to_sym) ? "_#{prifix}_#{joins.join('_')}" : "_#{prifix}"
25
26
  table_name = currentModel.name.underscore
26
27
  hash = {key => value}
27
28
  return self.model.send(function_name, models, table_name, hash)
28
29
  elsif associations[association].include?(key)
29
- joins.push key
30
+ # prifix = first association
31
+ prifix = association if prifix == ''
30
32
  models.joins_array!(joins)
31
33
  currentModel = key.camelize.singularize.constantize
32
34
  value.each do |k, v|
33
35
  # this fnuction collback
34
- models = relationSearch.call(models, currentModel, k, v, joins)
36
+ models = relationSearch.call(models, currentModel, k, v, prifix, joins)
35
37
  end
36
38
  end
37
39
  end
@@ -1,3 +1,3 @@
1
1
  module Baseapi
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
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.11
4
+ version: 0.1.12
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-09-01 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler