display_case 0.1.2 → 0.2.0
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 +22 -0
- data/lib/display_case/configuration.rb +9 -0
- data/lib/display_case/find_definitions.rb +12 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4e65f1433316f14dca449835da35f3f431c1163
|
4
|
+
data.tar.gz: 81f9de2392ef2ef606acea14d009b63c71ee72b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20eceab33a3c2feab1979a24ed53098eea29c0e8dce404d5e48488d47a1e4788dcab868cfc5e70e4ed5c27d45bb4eac2c1b9d718af2f43d09833e154c8bb7e0a
|
7
|
+
data.tar.gz: dfa1592a2e671d7d3eca646404ddc501139a3fd95d60e389dd0fbac7fdcd0f003fce1102c50cd4456f8ec6e6a511c1a338361349c1b0286567b1aa34b3608125
|
data/README.md
CHANGED
@@ -133,3 +133,25 @@ how to choose good keys.
|
|
133
133
|
Wrong url with extra parameters using an exhibited model?
|
134
134
|
------------------
|
135
135
|
See this issue for the reason: https://github.com/objects-on-rails/display-case/issues/8
|
136
|
+
|
137
|
+
|
138
|
+
TypeError: superclass mismatch for class MyExhibit
|
139
|
+
------------------
|
140
|
+
This error is common in development mode in code bases which `ExhibitB` inherits from `ExhibitA`, which inherits from `DisplayCase::Exhibit`.
|
141
|
+
DisplayCase is doing a lot of messing around with your exhibits to make them respond appropriately as if they were the object you're exhibiting,
|
142
|
+
and that is _normally_ the cause of this error if you're using inheritance among exhibits.
|
143
|
+
|
144
|
+
However, since it's possible you could actually be inadvertently having a superclass mismatch, the recommended way around this error is to avoid
|
145
|
+
the situation.
|
146
|
+
|
147
|
+
In case you're having this error, and you're confident that is _not_ happening, we do provide a configuration option to catch this
|
148
|
+
error and reload the class anyway. :warning: But be warned, if it is a legitimate superclass mismatch, you won't catch it with
|
149
|
+
this option turned on! :warning:
|
150
|
+
|
151
|
+
To turn on this option, in your DisplayCase initializer:
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
DisplayCase.configure do |config|
|
155
|
+
config.swallow_superclass_mismatch_for_exhibits = true
|
156
|
+
end
|
157
|
+
```
|
@@ -30,6 +30,10 @@ module DisplayCase
|
|
30
30
|
# A boolean indicating whether Exhibits with names that are similar to
|
31
31
|
# context should be favored over other exhibits. By default, this is true
|
32
32
|
attr_accessor :smart_matching
|
33
|
+
|
34
|
+
# A boolean indicating whether DisplayCase will swallow superclass mismatch
|
35
|
+
# errors (see README for more info). By default, this is false.
|
36
|
+
attr_accessor :swallow_superclass_mismatch_for_exhibits
|
33
37
|
|
34
38
|
def initialize
|
35
39
|
@definition_file_paths = %w(app/exhibits)
|
@@ -38,6 +42,7 @@ module DisplayCase
|
|
38
42
|
@cache_store = nil
|
39
43
|
@logging_enabled = false
|
40
44
|
@smart_matching = true
|
45
|
+
@swallow_superclass_mismatch_for_exhibits = false
|
41
46
|
end
|
42
47
|
|
43
48
|
def explicit?
|
@@ -47,6 +52,10 @@ module DisplayCase
|
|
47
52
|
def smart_matching?
|
48
53
|
smart_matching
|
49
54
|
end
|
55
|
+
|
56
|
+
def swallow_superclass_mismatch_for_exhibits?
|
57
|
+
swallow_superclass_mismatch_for_exhibits
|
58
|
+
end
|
50
59
|
|
51
60
|
def logging_enabled?
|
52
61
|
defined? ::Rails and logging_enabled
|
@@ -19,8 +19,18 @@ module DisplayCase
|
|
19
19
|
def self.display_case_load(file)
|
20
20
|
@file_changes ||= {}
|
21
21
|
if File.exists?(file) && (@file_changes[file].to_i < (mtime = File.mtime(file).to_i))
|
22
|
-
|
23
|
-
|
22
|
+
begin
|
23
|
+
load file
|
24
|
+
@file_changes[file] = mtime
|
25
|
+
rescue TypeError
|
26
|
+
klass = $!.message.gsub("superclass mismatch for class ", "").constantize
|
27
|
+
if klass.ancestors.include?(DisplayCase::Exhibit) && configuration.swallow_superclass_mismatch_for_exhibits?
|
28
|
+
Object.send(:remove_const, klass.name.to_sym)
|
29
|
+
retry
|
30
|
+
else
|
31
|
+
raise $!
|
32
|
+
end
|
33
|
+
end
|
24
34
|
end
|
25
35
|
end
|
26
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: display_case
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Avdi Grimm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An implementation of the Exhibit pattern, as described in Objects on
|
14
14
|
Rails
|
@@ -49,9 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
version: '0'
|
50
50
|
requirements: []
|
51
51
|
rubyforge_project:
|
52
|
-
rubygems_version: 2.
|
52
|
+
rubygems_version: 2.4.3
|
53
53
|
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: An implementation of the Exhibit pattern, as described in Objects on Rails
|
56
56
|
test_files: []
|
57
|
-
has_rdoc:
|