magic-presenter 1.3.0 → 1.4.0
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/README.md +23 -0
- data/app/models/concerns/magic/presentable.rb +2 -0
- data/lib/magic/presenter/base.rb +2 -0
- data/lib/magic/presenter/engine.rb +1 -1
- data/lib/magic/presenter/version.rb +1 -1
- data/lib/magic/presenter.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: 018f8d173f204bef93fdaf99a35417b1018a81517231f673a0dd44a1644ee61b
|
|
4
|
+
data.tar.gz: e0ca0e5a3b439b40e20d429f7f7ba35c48390f51debb30510445d4e1d682b948
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c2913873efd49741bf0991eb34cfd30e32ceede34a84eef752b86c951625cd173db3b4069473f16a0ecfc6e1ea8d26c9a75a8d8525a4e35c5d8e81e38346841
|
|
7
|
+
data.tar.gz: e28356ed613cc0f68f46618ba989956fd3dd467d91ec0bf81f1d9aced9f6504208a7dedff8ebd05bdfcb2bf7214d5dadc97ba961738928ee2fe09578a7b66eb5
|
data/README.md
CHANGED
|
@@ -55,6 +55,8 @@ person = Person.new(first_name: 'John', last_name: 'Smith').decorate
|
|
|
55
55
|
person.name # => "John Smith"
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
Use [load hooks](#load-hooks) to extend the base presenter functionality.
|
|
59
|
+
|
|
58
60
|
### `Magic::Presentable`
|
|
59
61
|
|
|
60
62
|
This module includes `Magic::Decoratable` and allows a descendant to be decorated by presenters only.
|
|
@@ -64,6 +66,8 @@ When no presenter is found,
|
|
|
64
66
|
- `#decorate!` raises `Magic::Lookup::Error`,
|
|
65
67
|
- `#decorated` returns the original object.
|
|
66
68
|
|
|
69
|
+
Use [load hooks](#load-hooks) to extend the functionality.
|
|
70
|
+
|
|
67
71
|
#### Collections
|
|
68
72
|
|
|
69
73
|
Active Record relations are presentable as collections. Define a collection presenter inside the matching presenter to customize collection behavior:
|
|
@@ -121,6 +125,25 @@ end
|
|
|
121
125
|
> [!NOTE]
|
|
122
126
|
> A valid `request` may be needed for URL helpers to get host data.
|
|
123
127
|
|
|
128
|
+
### Load hooks
|
|
129
|
+
|
|
130
|
+
Load hooks are triggered when `Magic::Presenter::Base` or `Magic::Presentable` are loaded.
|
|
131
|
+
They allow you to run custom initialization code for configuration or to extend the functionality.
|
|
132
|
+
|
|
133
|
+
```ruby
|
|
134
|
+
ActiveSupport.on_load :presenter do
|
|
135
|
+
# Put the code to be executed when Magic::Presenter is loaded here.
|
|
136
|
+
# It runs in the context of Magic::Presenter::Base class.
|
|
137
|
+
end
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```ruby
|
|
141
|
+
ActiveSupport.on_load :presentable do
|
|
142
|
+
# Put the code to be executed when Magic::Presentable is loaded here.
|
|
143
|
+
# It runs in the context of Magic::Presentable module.
|
|
144
|
+
end
|
|
145
|
+
```
|
|
146
|
+
|
|
124
147
|
## 🧙 Magic
|
|
125
148
|
|
|
126
149
|
> [!IMPORTANT]
|
data/lib/magic/presenter/base.rb
CHANGED
data/lib/magic/presenter.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: magic-presenter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Senko
|
|
@@ -111,7 +111,7 @@ licenses:
|
|
|
111
111
|
metadata:
|
|
112
112
|
homepage_uri: "https://github.com/Alexander-Senko/magic-presenter"
|
|
113
113
|
source_code_uri: "https://github.com/Alexander-Senko/magic-presenter"
|
|
114
|
-
changelog_uri: "https://github.com/Alexander-Senko/magic-presenter/blob/v1.
|
|
114
|
+
changelog_uri: "https://github.com/Alexander-Senko/magic-presenter/blob/v1.4.0/CHANGELOG.md"
|
|
115
115
|
rdoc_options: []
|
|
116
116
|
require_paths:
|
|
117
117
|
- lib
|