activesupport-decorators 2.0.2 → 2.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe3d5acccd16ca2bca25ff066e240f8897746828
|
4
|
+
data.tar.gz: 7294b4ce649697db9d74f5bfdc487970387fe760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8742c9b92ad8b9e926d21aab29a70f5674e04a49ee5ed32decd1c1afef5bc64e32f8d4ae99ad309fefc75b5796a7eaf1b468e73b66866ed3e4a76e81900a13c5
|
7
|
+
data.tar.gz: db6128c3c7b0bb8a54c311d855b2f75a5e1e16fcc792d463ea2f455768fc867f0129db331e947c163f3068c24b4d02d258f7d3894e9045d4f566f2c0d3eef38f
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
ActiveSupport Decorators
|
2
2
|
========================
|
3
3
|
|
4
|
-
[]
|
5
|
+
(https://travis-ci.org/EPI-USE-Labs/activesupport-decorators)
|
6
6
|
|
7
7
|
The decorator pattern is particularly useful when extending constants in rails engines or vice versa. To implement
|
8
8
|
the decorator pattern, you need to load the decorator after the original file has been loaded. When you reference a
|
@@ -68,14 +68,28 @@ module MyEngine
|
|
68
68
|
end
|
69
69
|
```
|
70
70
|
|
71
|
-
###
|
71
|
+
### Troubleshooting
|
72
72
|
|
73
|
-
|
73
|
+
1) Enable debug output to see which decorators are loaded:
|
74
74
|
|
75
75
|
```Ruby
|
76
76
|
ActiveSupportDecorators.debug = true
|
77
77
|
```
|
78
78
|
|
79
|
+
2) There is a standard ActiveSupport method available to see all load paths configured in your application. The file you
|
80
|
+
are trying to decorate should be on one of these:
|
81
|
+
|
82
|
+
```Ruby
|
83
|
+
ActiveSupport::Dependencies.autoload_paths
|
84
|
+
```
|
85
|
+
|
86
|
+
3) The relative path of the file you are trying to decorate in (2) should match the relative path of your decorator file
|
87
|
+
to your configured decorator paths:
|
88
|
+
|
89
|
+
```Ruby
|
90
|
+
ActiveSupportDecorators.expanded_paths
|
91
|
+
```
|
92
|
+
|
79
93
|
### Comparison to other gems
|
80
94
|
|
81
95
|
Other gems work by simply telling Rails to eager load all your decorators on application startup as seen [here]
|
@@ -38,7 +38,7 @@ module ActiveSupportDecorators
|
|
38
38
|
if const_path
|
39
39
|
file = const_path.underscore
|
40
40
|
else
|
41
|
-
first_autoload_match =
|
41
|
+
first_autoload_match = ActiveSupport::Dependencies.autoload_paths.find { |p| file.include?(p) }
|
42
42
|
file.sub!(first_autoload_match, '') if first_autoload_match
|
43
43
|
end
|
44
44
|
|
@@ -58,12 +58,6 @@ module ActiveSupportDecorators
|
|
58
58
|
end
|
59
59
|
|
60
60
|
private
|
61
|
-
def self.all_autoload_paths
|
62
|
-
return [] unless defined?(Rails)
|
63
|
-
all_modules = [::Rails.application] + ::Rails::Engine.subclasses.map(&:instance)
|
64
|
-
all_modules.map { |mod| mod.send(:_all_autoload_paths) }.flatten
|
65
|
-
end
|
66
|
-
|
67
61
|
def self.sanitize(file_name)
|
68
62
|
file_name.sub(/\.rb$/, '')
|
69
63
|
end
|
@@ -11,7 +11,7 @@ describe ActiveSupportDecorators do
|
|
11
11
|
|
12
12
|
describe 'when configuring a decorator path' do
|
13
13
|
before :each do
|
14
|
-
|
14
|
+
ActiveSupport::Dependencies.stub(:autoload_paths) do
|
15
15
|
[File.join(File.dirname(__FILE__), 'support', 'originals')]
|
16
16
|
end
|
17
17
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activesupport-decorators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Pretorius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|