display_case 0.0.3 → 0.0.4
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.
- data/README.md +5 -1
- data/lib/display_case/exhibit.rb +7 -4
- data/lib/display_case/railtie.rb +4 -2
- metadata +6 -3
data/README.md
CHANGED
@@ -42,7 +42,7 @@ class LeagueExhibit < DisplayCase::Exhibit
|
|
42
42
|
end
|
43
43
|
```
|
44
44
|
|
45
|
-
Then in your controller, where you're instantiating a League, wrap it in a call to the `exhibit` helper to
|
45
|
+
Then in your controller, where you're instantiating a League, wrap it in a call to the `exhibit` helper to get the Exhibited object, rather than the raw one.
|
46
46
|
``` ruby
|
47
47
|
# app/controllers/leagues_controller.rb
|
48
48
|
class LeaguesController < ApplicationController
|
@@ -85,3 +85,7 @@ DisplayCase.configure do |config|
|
|
85
85
|
config.exhibits = [MyFirstExhibit,MySecondExhibit]
|
86
86
|
end
|
87
87
|
```
|
88
|
+
|
89
|
+
Wrong url with extra parameters using an exhibited model?
|
90
|
+
------------------
|
91
|
+
See this issue for the reason: https://github.com/objects-on-rails/display-case/issues/8
|
data/lib/display_case/exhibit.rb
CHANGED
@@ -21,14 +21,17 @@ module DisplayCase
|
|
21
21
|
|
22
22
|
def self.exhibit(object, context)
|
23
23
|
return object if exhibited_object?(object)
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
if defined? Rails
|
25
|
+
Rails.logger.debug "Registered exhibits: #{@@exhibits}"
|
26
|
+
Rails.logger.debug "Exhibiting #{object.inspect}"
|
27
|
+
Rails.logger.debug "Exhibit context: #{context}"
|
28
|
+
end
|
29
|
+
|
27
30
|
object = Exhibited.new(object, context)
|
28
31
|
exhibits.inject(object) do |object, exhibit_class|
|
29
32
|
exhibit_class.exhibit_if_applicable(object, context)
|
30
33
|
end.tap do |obj|
|
31
|
-
Rails.logger.debug "Exhibits applied: #{obj.inspect_exhibits}"
|
34
|
+
Rails.logger.debug "Exhibits applied: #{obj.inspect_exhibits}" if defined? Rails
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
data/lib/display_case/railtie.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module DisplayCase
|
2
2
|
class Railtie < Rails::Railtie
|
3
|
+
# http://guides.rubyonrails.org/configuring.html#initialization-events
|
4
|
+
# "to_prepare will run upon every request in development, but only once (during boot-up) in production and test."
|
3
5
|
config.to_prepare do
|
4
|
-
DisplayCase.find_definitions
|
6
|
+
DisplayCase.find_definitions
|
5
7
|
end
|
6
8
|
end
|
7
|
-
end
|
9
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: display_case
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: An implementation of the Exhibit pattern, as described in Objects on
|
15
15
|
Rails
|
@@ -40,6 +40,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- - ! '>='
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
hash: -3671993401074233361
|
43
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
47
|
none: false
|
45
48
|
requirements:
|
@@ -48,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
51
|
version: '0'
|
49
52
|
requirements: []
|
50
53
|
rubyforge_project:
|
51
|
-
rubygems_version: 1.8.
|
54
|
+
rubygems_version: 1.8.10
|
52
55
|
signing_key:
|
53
56
|
specification_version: 3
|
54
57
|
summary: An implementation of the Exhibit pattern, as described in Objects on Rails
|