activeadmin_decorator 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/activeadmin/arbre_decorator.rb +2 -29
- data/lib/activeadmin_decorator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9066952cd77bd579269b0bf534618271ad135a974fdf9d837ea35e416c8508d6
|
4
|
+
data.tar.gz: 93750f0e9c841dbf9408c5463d9453895c8f796e059290faf761fdad14123001
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 351b713fde7f9a5c868861cb75e1ed6d91646d5657f07955a1c6ab0b0ea6af8e45b13121cfeba35bfbe5d809cc07861dd6b688d4a78752c0fff6b036a983ad21
|
7
|
+
data.tar.gz: f812a8602b9365810bc9d8da56c40d09b677e4622ee8bc102f11b4bbdbf4c660596e2309b90630cdcfd05f0c2f1e5f6407459dc54cf75dfbd65efa9d02b7f84f
|
data/README.md
CHANGED
@@ -45,15 +45,15 @@ With `ActiveAdmin::ArbreDecorator` you can keep your show/index blocks in AA cle
|
|
45
45
|
```ruby
|
46
46
|
class UserDecorator < ActiveAdmin::ArbreDecorator
|
47
47
|
def full_name
|
48
|
-
ul do
|
49
|
-
|
50
|
-
|
48
|
+
ul do
|
49
|
+
li first_name
|
50
|
+
li last_name
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
54
|
```
|
55
55
|
|
56
|
-
Also included: `
|
56
|
+
Also included: `ActionView::Helpers` and `Rails.application.routes.url_helpers`,
|
57
57
|
so you can:
|
58
58
|
```ruby
|
59
59
|
class CommentDecorator < ActiveAdmin::ArbreDecorator
|
@@ -4,43 +4,16 @@ require_relative 'decorator'
|
|
4
4
|
|
5
5
|
module ActiveAdmin
|
6
6
|
class ArbreDecorator < Decorator
|
7
|
-
include ActiveAdmin::ViewHelpers
|
8
7
|
include ActionView::Helpers
|
9
|
-
|
10
|
-
CONFLICTING_METHODS = %i[display_name title].freeze
|
8
|
+
include Arbre::Element::BuilderMethods
|
11
9
|
|
12
10
|
def initialize(obj)
|
13
11
|
super
|
14
12
|
singleton_class.include Rails.application.routes.url_helpers
|
15
|
-
CONFLICTING_METHODS.each do |method|
|
16
|
-
define_singleton_method(method) { obj.send(method) } if !custom_method?(method) && obj.respond_to?(method)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
ruby2_keywords def method_missing(method, *args, &block)
|
21
|
-
if cached_arbre_element.respond_to?(method) && !model.respond_to?(method)
|
22
|
-
Arbre::Context.new(model:) do
|
23
|
-
__send__(method, *args, &block)
|
24
|
-
end
|
25
|
-
else
|
26
|
-
super
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def respond_to?(method, include_private = false)
|
31
|
-
return false if CONFLICTING_METHODS.include?(method) && !model.respond_to?(method) && !custom_method?(method)
|
32
|
-
|
33
|
-
super
|
34
13
|
end
|
35
14
|
|
36
15
|
private
|
37
16
|
|
38
|
-
def
|
39
|
-
@cached_arbre_element ||= Arbre::Element.new
|
40
|
-
end
|
41
|
-
|
42
|
-
def custom_method?(method_name)
|
43
|
-
methods.include?(method_name) && method(method_name).owner < ArbreDecorator
|
44
|
-
end
|
17
|
+
def arbre_context = @arbre_context ||= Arbre::Context.new
|
45
18
|
end
|
46
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Papis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeadmin
|