excalibur 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/excalibur/version.rb +1 -1
- data/lib/excalibur/view_helpers.rb +7 -5
- data/spec/lib/excalibur/view_helper_spec.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c85c0ba73e611090f63258ee7c7b8fa79e3632fa
|
4
|
+
data.tar.gz: 8aebb1d1e7773f82e714dbf9fcddcccadcde6cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ac3b09b2468035e81b06aa978b6586169452fa9df834af3a1def3b8580384396c571fad45b1034962823b2828e3e783d5c0aee5adf90152f4ce8e7b9f4dcc41
|
7
|
+
data.tar.gz: dbe90aa2c8de7ecfa381514aee7c9959487f8f6680812d9841fdf3fe263d10204683e3d26c8011c27f93c72d937f39f3ef15939f7de7265610136ad49340477c
|
data/README.md
CHANGED
@@ -90,6 +90,16 @@ context.
|
|
90
90
|
entitle @your_object, config: @custom_config
|
91
91
|
```
|
92
92
|
|
93
|
+
In some cases the object you are trying to ```entitle``` will be of a
|
94
|
+
different class than you would have the decorator created for. You might work
|
95
|
+
with single table inheritance or are using sub-classes. In this case you can
|
96
|
+
pass a ```:class_name``` option. That will be used to find the correct
|
97
|
+
excalibur decorator in your app.
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
entitle @your_object, class_name: CustomKlass
|
101
|
+
```
|
102
|
+
|
93
103
|
### Views without an object
|
94
104
|
|
95
105
|
In some cases you might not have an object to present. Like when on a
|
data/lib/excalibur/version.rb
CHANGED
@@ -64,11 +64,13 @@ module Excalibur
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def excalibur_decorate_subject(object, options = {})
|
67
|
-
class_name =
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
class_name = if options.key?(:class_name)
|
68
|
+
options.delete(:class_name)
|
69
|
+
elsif object.is_a?(Draper::Decorator)
|
70
|
+
object.object.class.name
|
71
|
+
else
|
72
|
+
object.class.name
|
73
|
+
end
|
72
74
|
|
73
75
|
Object.const_get(
|
74
76
|
"::Excalibur::#{class_name}Decorator"
|
@@ -33,6 +33,22 @@ module Excalibur
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
context 'when dealing with a custom object' do
|
37
|
+
let(:obj) { true }
|
38
|
+
|
39
|
+
it 'should try and decorate an object from a class' do
|
40
|
+
expect(DummyDecorator).to receive(:decorate).with(obj, {})
|
41
|
+
|
42
|
+
helpers.entitle(obj, class_name: Dummy)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should try and decorate an object from a string' do
|
46
|
+
expect(DummyDecorator).to receive(:decorate).with(obj, {})
|
47
|
+
|
48
|
+
helpers.entitle(obj, class_name: 'Dummy')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
36
52
|
context 'when dealing with a decorated object' do
|
37
53
|
let(:origin) { Dummy.new }
|
38
54
|
let(:obj) { OtherDecorator.decorate(origin) }
|