corn_starch 1.1.22 → 1.1.23
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/app/controllers/corn_starch/corn_starch_controller.rb +50 -49
- data/lib/corn_starch/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: 79dd6e86400c8a8304ce22a95a1d5215ac3ac781
|
4
|
+
data.tar.gz: 6c804297a842534f78a9d9e1b3a001f61a102f9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afd3f3a774e8042740b9169bb4a55a92ad60efab7a270c83ff7c139152070d24cfb84a0300dbc5a9597bd577533837eea6ef1942b9214c2c3e0eceae0a905234
|
7
|
+
data.tar.gz: 7397fb82f6630e6db6d032aba2bd41076fa8726b0fd66f8c3dff16e44e9e064bc9366c98f14b0af04de25c93270c5d3c9c0e2a182c5987bc420b9b99b9cb936a
|
@@ -19,55 +19,6 @@ module CornStarch
|
|
19
19
|
# Use the Application's Layout
|
20
20
|
layout 'layouts/application'
|
21
21
|
|
22
|
-
####################
|
23
|
-
# Controller Utils #
|
24
|
-
####################
|
25
|
-
|
26
|
-
# Universal Search
|
27
|
-
def unisearch model, search
|
28
|
-
|
29
|
-
# Check Search
|
30
|
-
return model unless search
|
31
|
-
|
32
|
-
# Initialize Variables
|
33
|
-
search_model = model
|
34
|
-
search_q = ''
|
35
|
-
search_a = []
|
36
|
-
search_fields = {}
|
37
|
-
|
38
|
-
# Run through Model's Associations
|
39
|
-
model.searchable_associations.each do |a|
|
40
|
-
|
41
|
-
# Join into Search Model
|
42
|
-
search_model = search_model.includes a
|
43
|
-
|
44
|
-
# Acquire Association Target Model
|
45
|
-
assoc = model.reflect_on_association(a).klass
|
46
|
-
|
47
|
-
# Add Target Model's Search Fields
|
48
|
-
search_fields[assoc.table_name] = assoc.searchable_attributes
|
49
|
-
end
|
50
|
-
|
51
|
-
# Add Base Model's Search Fields
|
52
|
-
search_fields[model.table_name] = []
|
53
|
-
model.searchable_attributes.each { |a| search_fields[model.table_name] << a }
|
54
|
-
|
55
|
-
# Run through Search Fields Models
|
56
|
-
search_fields.each do |m|
|
57
|
-
|
58
|
-
# Run through Model's Fields
|
59
|
-
m.each do |f|
|
60
|
-
|
61
|
-
# Build Search Query & Arguments Array
|
62
|
-
search_q = search_q + "#{m}.#{f} LIKE ? "
|
63
|
-
search_a << "%#{search}%"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# Perform Search and eliminate doubles
|
68
|
-
search_model.where(search_q, *search_a).references(model.table_name).uniq
|
69
|
-
end
|
70
|
-
|
71
22
|
# Private
|
72
23
|
private
|
73
24
|
|
@@ -140,6 +91,56 @@ module CornStarch
|
|
140
91
|
params[:id] == current_user.id.to_s
|
141
92
|
end
|
142
93
|
|
94
|
+
# Get Records
|
95
|
+
def get_records model, params
|
96
|
+
paginate unisearch(model, params[:search]), params
|
97
|
+
end
|
98
|
+
|
99
|
+
# Universal Search
|
100
|
+
def unisearch model, search
|
101
|
+
|
102
|
+
# Check Search
|
103
|
+
return model unless search
|
104
|
+
|
105
|
+
# Initialize Variables
|
106
|
+
search_model = model
|
107
|
+
search_q = ''
|
108
|
+
search_a = []
|
109
|
+
search_fields = {}
|
110
|
+
|
111
|
+
# Run through Model's Associations
|
112
|
+
model.searchable_associations.each do |a|
|
113
|
+
|
114
|
+
# Join into Search Model
|
115
|
+
search_model = search_model.includes a
|
116
|
+
|
117
|
+
# Acquire Association Target Model
|
118
|
+
assoc = model.reflect_on_association(a).klass
|
119
|
+
|
120
|
+
# Add Target Model's Search Fields
|
121
|
+
search_fields[assoc.table_name] = assoc.searchable_attributes
|
122
|
+
end
|
123
|
+
|
124
|
+
# Add Base Model's Search Fields
|
125
|
+
search_fields[model.table_name] = []
|
126
|
+
model.searchable_attributes.each { |a| search_fields[model.table_name] << a }
|
127
|
+
|
128
|
+
# Run through Search Fields Models
|
129
|
+
search_fields.each do |m|
|
130
|
+
|
131
|
+
# Run through Model's Fields
|
132
|
+
m.each do |f|
|
133
|
+
|
134
|
+
# Build Search Query & Arguments Array
|
135
|
+
search_q = search_q + "#{m}.#{f} LIKE ? "
|
136
|
+
search_a << "%#{search}%"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# Perform Search and eliminate doubles
|
141
|
+
search_model.where(search_q, *search_a).references(model.table_name).uniq
|
142
|
+
end
|
143
|
+
|
143
144
|
# Paginate
|
144
145
|
def paginate collection, params
|
145
146
|
|
data/lib/corn_starch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: corn_starch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eresse
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|