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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e73905a05488d0f31f7bee41eef8755cfd72010
4
- data.tar.gz: 9d8eb4c51d7996a0faff11fcc93977773b83257e
3
+ metadata.gz: 1316bfc8127d428511d73ac6076fe7ca6bb271fe
4
+ data.tar.gz: c6470804f8d7339dc0222c494c8c8afc9f3ef7b4
5
5
  SHA512:
6
- metadata.gz: 631f7546330c3bbefeafb82e8ccf2cd0cc6b7c89b990c6f5c60bcdcb967ea3f9865adcf320bbb5dc9a13d689ed9a04ebdcaa8a9ace15dfd4c951e9946c65ab3c
7
- data.tar.gz: 9d81f8a6b01e62e92dfe7a982696e7193bfb4655785521ff8173b61e4d2245dd4bb506103791266490f4d5517174ca244360e6f6922be4d1c1f4c0eaff3a2f6b
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:install [class name]
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
@@ -1,4 +1,4 @@
1
1
  # setting version number for the Excalibur gem
2
2
  module Excalibur
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
@@ -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::#{object.class.name}Decorator"
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
- let(:obj) { Dummy.new }
19
+ context 'when dealing with a blank object' do
20
+ let(:obj) { Dummy.new }
19
21
 
20
- it 'should try and decorate an object' do
21
- expect(DummyDecorator).to receive(:decorate).with(obj, {})
22
+ it 'should try and decorate an object' do
23
+ expect(DummyDecorator).to receive(:decorate).with(obj, {})
22
24
 
23
- helpers.entitle(obj, {})
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
- it 'should set an instance variable' do
27
- helpers.entitle(obj, {})
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
- expect(helpers.instance_variable_get(:@excalibur_subject)).to be_present
30
- expect(helpers.instance_variable_get(:@excalibur_subject)).to be_instance_of DummyDecorator
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
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-13 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails