api_helper 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aeda154cc88246fbd37bbce92133f4e73feee7a7
4
- data.tar.gz: 403c2eb669b8b1ba866f4cec3875f44bf35528ef
3
+ metadata.gz: 0b3c62a17cbcc5826c91653645c8c2d74ad5816c
4
+ data.tar.gz: 756983a3ff914855c209e919ed2005d44426f8f8
5
5
  SHA512:
6
- metadata.gz: 55d8d8cc853e75cf8d75c2fc45523a35d773daffbf289e5df47d016b2e95378a05801c2a909d78687195ade2787253d2b8501ef852ed441475bed783438b3d51
7
- data.tar.gz: c15c43fe4804b574b458ebeba1f8e2c55865cee75d6bedd42e53c0c103d189813f1c382aba5bc5c314e011accf84f91da24f27bff9fd6ce631b8663c2b64d8d8
6
+ metadata.gz: 4bfbe426ec912739f3126e9d686522fae232ff637128d6516482fbc1490d1f35e893f7a772deccb2c26fc50f6becee0144dfd49af24238640e5df7e55b25b811
7
+ data.tar.gz: 8ea1bb0c2fa17ba9b5280e45f3c6789da3ad6ea540739b635543c14ef8c94ca22beee35441fd1f6f7477edb6ae6d5fe8397f35a7ac6f254d6f5c94fcf480f8d2
data/README.md CHANGED
@@ -49,9 +49,9 @@ Include each helper concern you need in an `ActionController::Base`:
49
49
 
50
50
  ```ruby
51
51
  PostsController < ApplicationController
52
- include APIHelpers::Filterable
53
- include APIHelpers::Paginatable
54
- include APIHelpers::Sortable
52
+ include APIHelper::Filterable
53
+ include APIHelper::Paginatable
54
+ include APIHelper::Sortable
55
55
 
56
56
  # ...
57
57
 
@@ -66,9 +66,9 @@ Set the helpers you need in an `Grape::API`:
66
66
 
67
67
  ```ruby
68
68
  class PostsAPI < Grape::API
69
- helpers APIHelpers::Filterable
70
- helpers APIHelpers::Paginatable
71
- helpers APIHelpers::Sortable
69
+ helpers APIHelper::Filterable
70
+ helpers APIHelper::Paginatable
71
+ helpers APIHelper::Sortable
72
72
 
73
73
  # ...
74
74
 
@@ -40,7 +40,7 @@ require 'active_support/core_ext/object/blank'
40
40
  # Include this +Concern+ in your Action Controller:
41
41
  #
42
42
  # SamplesController < ApplicationController
43
- # include APIHelpers::Filterable
43
+ # include APIHelper::Filterable
44
44
  # end
45
45
  #
46
46
  # or in your Grape API class:
@@ -71,7 +71,7 @@ module APIHelper::Filterable
71
71
  # +Array+ of +Symbol+s fields that are allowed to be filtered, defaults
72
72
  # to all
73
73
  #
74
- def filter(resource, filterable_fields: [])
74
+ def filter(resource, filterable_fields: [], ignore_unknown_fields: true)
75
75
  # parse the request parameter
76
76
  if params[:filter].is_a?(Hash) ||
77
77
  defined?(Rails) && Rails.version.to_i >= 5 && params[:filter].is_a?(ActionController::Parameters)
@@ -86,8 +86,8 @@ module APIHelper::Filterable
86
86
  # escape string to prevent SQL injection
87
87
  field = resource.connection.quote_string(field)
88
88
 
89
- next if resource.columns_hash[field].blank?
90
- field_type = resource.columns_hash[field].type
89
+ next if ignore_unknown_fields && resource.columns_hash[field].blank?
90
+ field_type = resource.columns_hash[field] && resource.columns_hash[field].type || :unknown
91
91
 
92
92
  # if a function is used
93
93
  if func = condition.match(/(?<function>[^\(\)]+)\((?<param>.*)\)/)
@@ -1,3 +1,3 @@
1
1
  module APIHelper
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-07 00:00:00.000000000 Z
11
+ date: 2016-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  version: '0'
203
203
  requirements: []
204
204
  rubyforge_project:
205
- rubygems_version: 2.5.1
205
+ rubygems_version: 2.4.6
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Helpers for creating standard web API.