eitil 1.1.22 → 1.1.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/eitil_core/README.md +5 -2
- data/eitil_core/lib/eitil_core/active_record.rb +1 -1
- data/eitil_core/lib/eitil_core/active_record/{hash_to_relation.rb → array_to_relation.rb} +3 -3
- data/eitil_wrapper/lib/eitil_wrapper/decorators/controller_decorator.rb +9 -5
- data/lib/eitil/railtie.rb +2 -0
- data/lib/eitil/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2898766e78bb6b5706c24111deb28ee19f479a45f7d475d05d096843eb1cb748
|
4
|
+
data.tar.gz: 6240c052572bd8d9cf269c266863e5556e601f360ca99b8aaecc3a002daf7365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 738bff100d4821b81d50a4f3b64bdd41b7d39ebc8dab0ee49a4124c51e6a35428f50f44a9c8cc14aaa5a8998edbc5446b517b09ccf47dafb44e2d64569a9d1ac
|
7
|
+
data.tar.gz: 40fb5472c8dafdf3e63e7ecea76f904467997100ee78e080cf8e384544bb8a9e488d1f0a0adb293a67fe182072fa2e144acf201b259db7f293fad006c457def2
|
data/eitil_core/README.md
CHANGED
@@ -15,11 +15,14 @@ require "eitil_core/active_record"
|
|
15
15
|
```
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
# require "eitil_core/active_record/
|
18
|
+
# require "eitil_core/active_record/array_to_relation"
|
19
19
|
|
20
|
-
[].to_relation
|
20
|
+
[].to_relation(fallback_class = ApplicationRecord)
|
21
21
|
# converts an array of ActiveRecord instances to an ActiveRecord_Relation instance
|
22
22
|
# call as: [#<instance1>,<instance2>].to_relation
|
23
|
+
|
24
|
+
# if the object is an empty array, the intended class cannot be derived from the object, so in order to
|
25
|
+
# prevent NoMethodError's you can optionally pass a fallback class which will be used to create an empty association
|
23
26
|
```
|
24
27
|
|
25
28
|
## ApplicationController
|
@@ -1,2 +1,2 @@
|
|
1
1
|
|
2
|
-
require "eitil_core/active_record/
|
2
|
+
require "eitil_core/active_record/array_to_relation"
|
@@ -1,18 +1,18 @@
|
|
1
1
|
|
2
|
-
# require "eitil_core/active_record/
|
2
|
+
# require "eitil_core/active_record/array_to_relation"
|
3
3
|
|
4
4
|
require "eitil_core/errors/raise_error"
|
5
5
|
|
6
6
|
class Array
|
7
7
|
|
8
|
-
def to_relation
|
8
|
+
def to_relation(fallback_class = ApplicationRecord)
|
9
9
|
|
10
10
|
# Return an empty ActiveRecord_Relation instance when no objects are present,
|
11
11
|
# instead of returning the empty array itself. The reason being, that when you
|
12
12
|
# always return an association, you won't run into problems with undefined methods
|
13
13
|
# called later on, expecting an association instead of an array.
|
14
14
|
|
15
|
-
return
|
15
|
+
return fallback_class.none unless self.present?
|
16
16
|
|
17
17
|
unless self.all? { |item| item.class.ancestors.include? ApplicationRecord }
|
18
18
|
raise_error "InvalidArrayError", ".to_relation requires that all array items are model instances"
|
@@ -5,7 +5,7 @@ module EitilWrapper
|
|
5
5
|
|
6
6
|
def decorate(dec_item, dec_method: nil, dec_class: nil, **dec_kwargs)
|
7
7
|
all_args_to_ivars binding
|
8
|
-
set_ivars :dec_class, :
|
8
|
+
set_ivars :dec_class, :decorator, :dec_method
|
9
9
|
send_to_decorator
|
10
10
|
end
|
11
11
|
|
@@ -29,9 +29,9 @@ module EitilWrapper
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def derived_dec_method
|
32
|
-
return unless respond_to? :params
|
33
|
-
return :app if params["isMobile"]
|
34
|
-
return :web if params["isWeb"]
|
32
|
+
return unless respond_to? :params
|
33
|
+
return :app if @decorator.respond_to?(:app) && params["isMobile"]
|
34
|
+
return :web if @decorator.respond_to?(:web) && params["isWeb"]
|
35
35
|
end
|
36
36
|
|
37
37
|
def set_dec_class
|
@@ -47,7 +47,7 @@ module EitilWrapper
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def set_decorator
|
50
|
-
@
|
50
|
+
@dec_class.new ivars
|
51
51
|
end
|
52
52
|
|
53
53
|
def controller_ivars
|
@@ -56,5 +56,9 @@ module EitilWrapper
|
|
56
56
|
end.inject &:merge
|
57
57
|
end
|
58
58
|
|
59
|
+
def ivars
|
60
|
+
@dec_kwargs ? controller_ivars.merge(@dec_kwargs) : controller_ivars
|
61
|
+
end
|
62
|
+
|
59
63
|
end
|
60
64
|
end
|
data/lib/eitil/railtie.rb
CHANGED
data/lib/eitil/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eitil
|
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
|
- Jurriaan Schrofer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -83,7 +83,7 @@ files:
|
|
83
83
|
- eitil_core/README.md
|
84
84
|
- eitil_core/lib/eitil_core.rb
|
85
85
|
- eitil_core/lib/eitil_core/active_record.rb
|
86
|
-
- eitil_core/lib/eitil_core/active_record/
|
86
|
+
- eitil_core/lib/eitil_core/active_record/array_to_relation.rb
|
87
87
|
- eitil_core/lib/eitil_core/application_controller.rb
|
88
88
|
- eitil_core/lib/eitil_core/application_controller/permit_model_atts.rb
|
89
89
|
- eitil_core/lib/eitil_core/application_controller/slice_params.rb
|