excalibur 0.0.5 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1316bfc8127d428511d73ac6076fe7ca6bb271fe
4
- data.tar.gz: c6470804f8d7339dc0222c494c8c8afc9f3ef7b4
3
+ metadata.gz: c85c0ba73e611090f63258ee7c7b8fa79e3632fa
4
+ data.tar.gz: 8aebb1d1e7773f82e714dbf9fcddcccadcde6cb2
5
5
  SHA512:
6
- metadata.gz: b592599d73cfaf217d3c4b1034b079be3d10d23031515602d66817a71bf0a99bf3d96c10b4cb2b2f8d65cee3705eabdfc5308e650a7daf2e3bd67af81f9e9d85
7
- data.tar.gz: b1acb7dfa01d296a25fac74c0c60de880cb066cf275ffd757d531a2fc76a7d5cb9f0742700532c12938f8d9d11c239bdb817a259514c1df9c024df1f09e72882
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
@@ -1,4 +1,4 @@
1
1
  # setting version number for the Excalibur gem
2
2
  module Excalibur
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
@@ -64,11 +64,13 @@ 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
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) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excalibur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joost Elfering