draper 4.0.5 → 4.0.6
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/CHANGELOG.md +5 -0
- data/lib/draper/collection_decorator.rb +6 -0
- data/lib/draper/decorator.rb +18 -2
- data/lib/draper/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: c37ab7e42fe93c37a13899d6b51f1dbddfcb7a417eaad7531a3e11d59fb63442
|
|
4
|
+
data.tar.gz: 3ab092943fa340ef28abfe4974960201374f92e2defa6bd1c8fd90cd495b6056
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d700dbac01e145361e56c8b6fbf04c93b9156492e14659ba6724fa36be20ebdac6319c2bc2910beaf68b9cbe40271808ed17c23bed2c8a76361d438cc5b35033
|
|
7
|
+
data.tar.gz: bd8689b7de4f934d97dc48a564795ef91e2e859b586f7561c0ba3996e0f2b7434a29d8a9e497d5248b0e28074b854befdb86f6f20858f1816474755ec14fdca3
|
data/CHANGELOG.md
CHANGED
data/lib/draper/decorator.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Draper
|
|
|
33
33
|
options.assert_valid_keys(:context)
|
|
34
34
|
@object = object
|
|
35
35
|
@context = options.fetch(:context, {})
|
|
36
|
-
handle_multiple_decoration(options) if object.
|
|
36
|
+
handle_multiple_decoration(options) if object.instance_of?(self.class)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
class << self
|
|
@@ -185,6 +185,22 @@ module Draper
|
|
|
185
185
|
self.class.hash ^ object.hash
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
+
# Checks if `self.kind_of?(klass)` or `object.kind_of?(klass)`
|
|
189
|
+
#
|
|
190
|
+
# @param [Class] klass
|
|
191
|
+
def kind_of?(klass)
|
|
192
|
+
super || object.kind_of?(klass)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
alias :is_a? :kind_of?
|
|
196
|
+
|
|
197
|
+
# Checks if `self.instance_of?(klass)` or `object.instance_of?(klass)`
|
|
198
|
+
#
|
|
199
|
+
# @param [Class] klass
|
|
200
|
+
def instance_of?(klass)
|
|
201
|
+
super || object.instance_of?(klass)
|
|
202
|
+
end
|
|
203
|
+
|
|
188
204
|
delegate :to_s
|
|
189
205
|
|
|
190
206
|
# In case object is nil
|
|
@@ -251,7 +267,7 @@ module Draper
|
|
|
251
267
|
if object.applied_decorators.last == self.class
|
|
252
268
|
@context = object.context unless options.has_key?(:context)
|
|
253
269
|
@object = object.object
|
|
254
|
-
|
|
270
|
+
else
|
|
255
271
|
warn "Reapplying #{self.class} decorator to target that is already decorated with it. Call stack:\n#{caller(1).join("\n")}"
|
|
256
272
|
end
|
|
257
273
|
end
|
data/lib/draper/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: draper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeff Casimir
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2025-11-
|
|
12
|
+
date: 2025-11-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|