effective_resources 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/resources/forms.rb +2 -1
- data/app/models/effective/resources/init.rb +1 -1
- data/app/models/effective/resources/klass.rb +1 -5
- data/app/models/effective/resources/naming.rb +2 -2
- data/app/models/effective/resources/relation.rb +9 -2
- data/lib/effective_resources/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: 092de6a5657f044dc7d24ef202f01b47b666a2f7
|
4
|
+
data.tar.gz: cb227dbf96b28597e2d8d9e05823895dd383874a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bccc81b7dc7044112946de7037065d0db21256bf8cd573f9f76fd8cec53d7ea1973018a57df48128459c7282dd1d0fa424ea8ac3707b9597683388728a88a92
|
7
|
+
data.tar.gz: f06f6e0235e2e40dc429c42e1c8b274403457038baa2f1dfc6c2f73508db0d6f79acc9246fec35fb79f76f6d8100576dcac52aa8a61cd7ef5b8931dd22ff6182
|
@@ -8,7 +8,8 @@ module Effective
|
|
8
8
|
when :belongs_to
|
9
9
|
{ as: :select }.merge(search_form_field_collection(belongs_to(name)))
|
10
10
|
when :belongs_to_polymorphic
|
11
|
-
{ as: :grouped_select, polymorphic: true, collection: nil}
|
11
|
+
#{ as: :grouped_select, polymorphic: true, collection: nil}
|
12
|
+
{ as: :string }
|
12
13
|
when :has_and_belongs_to_many
|
13
14
|
{ as: :select }.merge(search_form_field_collection(has_and_belongs_to_many(name)))
|
14
15
|
when :has_many
|
@@ -35,7 +35,7 @@ module Effective
|
|
35
35
|
0.upto(names.length-1) do |index|
|
36
36
|
class_name = (names[index..-1].map { |name| name.classify } * '::')
|
37
37
|
|
38
|
-
if (@model_klass
|
38
|
+
if (@model_klass ||= class_name.safe_constantize).present?
|
39
39
|
@class_name = class_name
|
40
40
|
@namespaces = names[0...index]
|
41
41
|
break
|
@@ -12,7 +12,7 @@ module Effective
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def class_name # 'Effective::Post'
|
15
|
-
@class_name
|
15
|
+
@model_klass.try(:name) || @class_name || ''
|
16
16
|
end
|
17
17
|
|
18
18
|
def class_path # 'effective'
|
@@ -20,7 +20,7 @@ module Effective
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def namespaced_class_name # 'Admin::Effective::Post'
|
23
|
-
(namespaces.map { |name| name.classify } + [class_name]) * '::'
|
23
|
+
(namespaces.to_a.map { |name| name.classify } + [class_name]) * '::'
|
24
24
|
end
|
25
25
|
|
26
26
|
def namespace # 'admin/things'
|
@@ -54,14 +54,21 @@ module Effective
|
|
54
54
|
end
|
55
55
|
|
56
56
|
association = associated(name)
|
57
|
-
|
57
|
+
|
58
|
+
term = Effective::Attribute.new(sql_type, klass: (association.try(:klass) rescue nil) || klass).parse(value, name: name)
|
58
59
|
|
59
60
|
case sql_type
|
60
61
|
when :belongs_to, :has_and_belongs_to_many, :has_many, :has_one
|
61
62
|
relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
|
62
63
|
when :belongs_to_polymorphic
|
63
64
|
(type, id) = term.split('_')
|
64
|
-
|
65
|
+
|
66
|
+
if type.present? && id.present?
|
67
|
+
relation.where("#{sql_column} = ?", id).where("#{sql_column.sub('_id', '_type')} = ?", type)
|
68
|
+
else
|
69
|
+
id ||= Effective::Attribute.new(:integer).parse(term)
|
70
|
+
relation.where("#{sql_column} = ? OR #{sql_column.sub('_id', '_type')} = ?", id, (type || term))
|
71
|
+
end
|
65
72
|
when :effective_addresses
|
66
73
|
raise 'not yet implemented'
|
67
74
|
when :effective_obfuscation
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|