rao-resources_controller 0.0.3.pre → 0.0.4.pre
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52206198dfe86937fc5b48e9472ac37711c87cac
|
4
|
+
data.tar.gz: cd543305bc43b25247dc12bd967eb8fbe53d3030
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 665acdca753461367366ec756cab51e5724638894535dbe168637a8d226f3e2844ef7e9a2396c4d7456ca58f3742bc12448a04dc135af73e2f705a00590949d6
|
7
|
+
data.tar.gz: 2b8d3385e0f2e774a63367aca876fa542077740f907d263d54668230a5d61ae0fffea6fbe31a2d5fd5727a053256ce5e62496b361ec83bc439896ce65e2f33a5
|
@@ -6,13 +6,6 @@ module Rao
|
|
6
6
|
include RestResourceUrlsConcern
|
7
7
|
include ResourceInflectionsConcern
|
8
8
|
include LocationHistoryConcern
|
9
|
-
include ::Rao::Controller::QueryConditionsConcern
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def load_collection_scope
|
14
|
-
add_conditions_from_query(resource_class)
|
15
|
-
end
|
16
9
|
end
|
17
10
|
end
|
18
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rao-resources_controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rao
|
@@ -91,7 +91,6 @@ files:
|
|
91
91
|
- README.md
|
92
92
|
- Rakefile
|
93
93
|
- app/concerns/rao/controller/autosubmit_concern.rb
|
94
|
-
- app/concerns/rao/controller/query_conditions.rb
|
95
94
|
- app/concerns/rao/resources_controller/acts_as_list_concern.rb
|
96
95
|
- app/concerns/rao/resources_controller/acts_as_published_concern.rb
|
97
96
|
- app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
|
@@ -104,7 +103,6 @@ files:
|
|
104
103
|
- app/concerns/rao/resources_controller/resources_concern.rb
|
105
104
|
- app/concerns/rao/resources_controller/rest_actions_concern.rb
|
106
105
|
- app/concerns/rao/resources_controller/rest_resource_urls_concern.rb
|
107
|
-
- app/concerns/rao/resources_controller/search_form_concern.rb
|
108
106
|
- app/concerns/rao/resources_controller/sorting_concern.rb
|
109
107
|
- app/concerns/rao/resources_controller/will_paginate_concern.rb
|
110
108
|
- app/controllers/rao/resources_controller/base.rb
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module Rao
|
2
|
-
module Controller::QueryConditions
|
3
|
-
private
|
4
|
-
|
5
|
-
def add_conditions_from_query(scope)
|
6
|
-
if query_params.keys.include?('q')
|
7
|
-
condition_params = normalize_query_params(query_params)
|
8
|
-
else
|
9
|
-
condition_params = query_params
|
10
|
-
end
|
11
|
-
|
12
|
-
condition_params.reject.reject { |k,v| v.blank? }.each do |field, condition|
|
13
|
-
case field
|
14
|
-
when 'limit'
|
15
|
-
scope = scope.limit(condition.to_i)
|
16
|
-
when 'offset'
|
17
|
-
scope = scope.offset(condition.to_i)
|
18
|
-
when 'order'
|
19
|
-
scope = scope.order(condition)
|
20
|
-
when 'includes'
|
21
|
-
scope = scope.includes(condition.map(&:to_sym))
|
22
|
-
else
|
23
|
-
condition_statement = ::Api::ResourcesController::ConditionParser.new(scope, field, condition).condition_statement
|
24
|
-
scope = scope.where(condition_statement)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
scope
|
28
|
-
end
|
29
|
-
|
30
|
-
def query_params
|
31
|
-
default_query_params
|
32
|
-
end
|
33
|
-
|
34
|
-
def default_query_params
|
35
|
-
request.query_parameters.except(*default_query_params_exceptions)
|
36
|
-
end
|
37
|
-
|
38
|
-
def default_query_params_exceptions
|
39
|
-
%w(sort_by sort_direction utf8 commit page)
|
40
|
-
end
|
41
|
-
|
42
|
-
def normalize_query_params(params)
|
43
|
-
params['q'].each_with_object({}) { |(k, v), m| m[normalize_key(k)] = v }
|
44
|
-
end
|
45
|
-
|
46
|
-
def normalize_key(key)
|
47
|
-
splitted_key = key.split('_')
|
48
|
-
predicate = splitted_key.last
|
49
|
-
attribute = splitted_key[0..-2].join('_')
|
50
|
-
"#{attribute}(#{predicate})"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|