arel_search 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/arel_search/base.rb +22 -7
- data/lib/arel_search/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
data/lib/arel_search/base.rb
CHANGED
@@ -44,15 +44,18 @@ module ArelSearch
|
|
44
44
|
end
|
45
45
|
|
46
46
|
class SearchField
|
47
|
-
|
47
|
+
|
48
|
+
NAMESPACE_SYMBOL = '::'
|
49
|
+
|
50
|
+
attr_reader :name, :value, :association, :namespace, :arel_predication, :split, :base_model
|
48
51
|
|
49
52
|
def initialize(key, v, b_model)
|
50
|
-
@base_model
|
53
|
+
@base_model = b_model
|
51
54
|
split_key(key)
|
52
|
-
@association
|
53
|
-
self.name
|
54
|
-
self.arel_predication
|
55
|
-
@value
|
55
|
+
@association, @namespace = set_association_and_namespace(self.split[0])
|
56
|
+
self.name = self.split[1]
|
57
|
+
self.arel_predication = self.split[2]
|
58
|
+
@value = v
|
56
59
|
end
|
57
60
|
|
58
61
|
def scopify(scope, default_arel_table)
|
@@ -77,7 +80,7 @@ module ArelSearch
|
|
77
80
|
end
|
78
81
|
|
79
82
|
def model
|
80
|
-
|
83
|
+
"#{namespace}#{NAMESPACE_SYMBOL}#{association.camelize.singularize}".constantize
|
81
84
|
end
|
82
85
|
|
83
86
|
private
|
@@ -109,6 +112,18 @@ module ArelSearch
|
|
109
112
|
@@arel_predications ||= Arel::Predications.instance_methods.map(&:to_s)
|
110
113
|
end
|
111
114
|
|
115
|
+
def set_association_and_namespace(association_namespaced)
|
116
|
+
split = association_namespaced.split(NAMESPACE_SYMBOL)
|
117
|
+
if split.size > 1
|
118
|
+
namespace = split[0]
|
119
|
+
association = split[1]
|
120
|
+
else
|
121
|
+
namespace = ''
|
122
|
+
association = association_namespaced
|
123
|
+
end
|
124
|
+
return association, namespace
|
125
|
+
end
|
126
|
+
|
112
127
|
end
|
113
128
|
|
114
129
|
end
|
data/lib/arel_search/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Arel based search gem
|
15
15
|
email:
|