excalibur 0.0.4 → 0.0.5
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 +1 -1
- data/lib/excalibur/version.rb +1 -1
- data/lib/excalibur/view_helpers.rb +7 -1
- data/spec/lib/excalibur/view_helper_spec.rb +22 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1316bfc8127d428511d73ac6076fe7ca6bb271fe
|
4
|
+
data.tar.gz: c6470804f8d7339dc0222c494c8c8afc9f3ef7b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b592599d73cfaf217d3c4b1034b079be3d10d23031515602d66817a71bf0a99bf3d96c10b4cb2b2f8d65cee3705eabdfc5308e650a7daf2e3bd67af81f9e9d85
|
7
|
+
data.tar.gz: b1acb7dfa01d296a25fac74c0c60de880cb066cf275ffd757d531a2fc76a7d5cb9f0742700532c12938f8d9d11c239bdb817a259514c1df9c024df1f09e72882
|
data/README.md
CHANGED
@@ -116,7 +116,7 @@ meta tags and the title. So without a decorator for an object the view helper
|
|
116
116
|
|
117
117
|
To scaffold a decorator execute:
|
118
118
|
|
119
|
-
rails generate excalibur:
|
119
|
+
rails generate excalibur:decorator [class name]
|
120
120
|
|
121
121
|
A detailed description on how the decorators work can be found in the newly
|
122
122
|
created decorator class. As a side note the ```Excalibur::Decorator``` is a
|
data/lib/excalibur/version.rb
CHANGED
@@ -64,8 +64,14 @@ module Excalibur
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def excalibur_decorate_subject(object, options = {})
|
67
|
+
class_name = if object.is_a?(Draper::Decorator)
|
68
|
+
object.object.class.name
|
69
|
+
else
|
70
|
+
object.class.name
|
71
|
+
end
|
72
|
+
|
67
73
|
Object.const_get(
|
68
|
-
"::Excalibur::#{
|
74
|
+
"::Excalibur::#{class_name}Decorator"
|
69
75
|
).decorate(object, options)
|
70
76
|
end
|
71
77
|
end
|
@@ -4,6 +4,7 @@ require 'action_view/helpers'
|
|
4
4
|
|
5
5
|
class Dummy; end
|
6
6
|
class Klass; end
|
7
|
+
class OtherDecorator < Draper::Decorator; end
|
7
8
|
|
8
9
|
module Excalibur
|
9
10
|
class DummyDecorator < Decorator; end
|
@@ -15,19 +16,32 @@ module Excalibur
|
|
15
16
|
end
|
16
17
|
|
17
18
|
describe '#entitle' do
|
18
|
-
|
19
|
+
context 'when dealing with a blank object' do
|
20
|
+
let(:obj) { Dummy.new }
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
it 'should try and decorate an object' do
|
23
|
+
expect(DummyDecorator).to receive(:decorate).with(obj, {})
|
22
24
|
|
23
|
-
|
25
|
+
helpers.entitle(obj, {})
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should set an instance variable' do
|
29
|
+
helpers.entitle(obj, {})
|
30
|
+
|
31
|
+
expect(helpers.instance_variable_get(:@excalibur_subject)).to be_present
|
32
|
+
expect(helpers.instance_variable_get(:@excalibur_subject)).to be_instance_of DummyDecorator
|
33
|
+
end
|
24
34
|
end
|
25
35
|
|
26
|
-
|
27
|
-
|
36
|
+
context 'when dealing with a decorated object' do
|
37
|
+
let(:origin) { Dummy.new }
|
38
|
+
let(:obj) { OtherDecorator.decorate(origin) }
|
39
|
+
|
40
|
+
it 'should try and decorate an object' do
|
41
|
+
expect(DummyDecorator).to receive(:decorate).with(origin, {})
|
28
42
|
|
29
|
-
|
30
|
-
|
43
|
+
helpers.entitle(obj, {})
|
44
|
+
end
|
31
45
|
end
|
32
46
|
end
|
33
47
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excalibur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joost Elfering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|