introspective_grape 0.2.3 → 0.2.4
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 +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/introspective_grape/api.rb +5 -2
- data/lib/introspective_grape/filters.rb +6 -0
- data/lib/introspective_grape/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: 83d87bcd4a1b094140084f652e87311d763b4259
|
|
4
|
+
data.tar.gz: ad9cc7c59b4675a4b105e656c3bc82e7a6db2b45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1e241e2e6b14512efe1b3da193f3a382def1c7a953dc9790d4b6680f68b1168b2397d45be5a09e2641eb7b5e5a392f31e42a37148aec9e394e40a176c25b8cf
|
|
7
|
+
data.tar.gz: aa769217ebffabc67b73732108c7e56c77482e6bd48a6ff8b929f35bfd3491f99ea3881b08f2c02e8534957add7941687a47b7bf81db5b5a4963df7e86d588da
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
|
|
2
|
+
0.2.4 10/26/2016
|
|
3
|
+
==============
|
|
4
|
+
|
|
5
|
+
### Bug Fix
|
|
6
|
+
|
|
7
|
+
Validate the presence of required belongs_to associations.
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
Add a default_sort for the index action option, rather than relying on custom_filters or a default_scope.
|
|
12
|
+
|
|
2
13
|
0.2.3 10/21/2016
|
|
3
14
|
==============
|
|
4
15
|
### Bug Fix
|
|
@@ -397,9 +397,12 @@ module IntrospectiveGrape
|
|
|
397
397
|
end
|
|
398
398
|
|
|
399
399
|
def param_required?(model,f)
|
|
400
|
-
return false if skip_presence_validations.include? f
|
|
401
400
|
# Detect if the field is a required field for the create action
|
|
402
|
-
|
|
401
|
+
return false if skip_presence_validations.include? f
|
|
402
|
+
|
|
403
|
+
validated_field = (f =~ /_id/) ? f.to_s.sub(/_id\z/,'').to_sym : f.to_sym
|
|
404
|
+
|
|
405
|
+
model.validators_on(validated_field).any? {|v| v.kind_of? ActiveRecord::Validations::PresenceValidator }
|
|
403
406
|
end
|
|
404
407
|
|
|
405
408
|
def add_destroy_param(dsl,model,reflection)
|
|
@@ -4,6 +4,10 @@ module IntrospectiveGrape::Filters
|
|
|
4
4
|
# customer filters for the index in a method.
|
|
5
5
|
#
|
|
6
6
|
|
|
7
|
+
def default_sort(*args)
|
|
8
|
+
@default_sort ||= args
|
|
9
|
+
end
|
|
10
|
+
|
|
7
11
|
def custom_filter(*args)
|
|
8
12
|
custom_filters( *args )
|
|
9
13
|
end
|
|
@@ -72,6 +76,8 @@ module IntrospectiveGrape::Filters
|
|
|
72
76
|
end
|
|
73
77
|
|
|
74
78
|
def apply_filter_params(klass, model, api_params, params, records)
|
|
79
|
+
records = records.order(default_sort) if default_sort.present?
|
|
80
|
+
|
|
75
81
|
simple_filters(klass, model, api_params).each do |field|
|
|
76
82
|
next if params[field].blank?
|
|
77
83
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: introspective_grape
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josh Buermann
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-10-
|
|
11
|
+
date: 2016-10-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|