eager_decorator 0.0.1 → 0.0.2
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/.gitignore +1 -0
- data/README.md +6 -2
- data/lib/eager_decorator.rb +17 -1
- data/lib/eager_decorator/hooks.rb +11 -0
- data/lib/eager_decorator/railtie.rb +1 -3
- data/lib/eager_decorator/version.rb +1 -1
- data/spec/dummy/app/models/user.rb +1 -0
- data/spec/dummy/config.rb +0 -3
- metadata +5 -3
- data/lib/eager_decorator/decorator.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40c3bf410755b9dfcb50e51948c367550b1aeb21
|
4
|
+
data.tar.gz: 62a3e22b36b742d28eef28b3ef32ea86948e972c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c1e2c5f8a7f220da57b6c9deca25fb12be8598e00cdb213c97acc90a92ac96e32c9939f91bb344e24bbb2fe65f7dd301cc0b946b446978534426d646dd8f8ee
|
7
|
+
data.tar.gz: d8c20de6e4bc024ea026c57362431e0a1eee5acea78f95dbdef2e4e25a25e1b18a9d8b7328e46cf027b33d07af9836be36e4750c1a881586eaa13e6e2c55e16d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# EagerDecorator [](https://travis-ci.org/kouyaf77/eager_decorator)
|
1
|
+
# EagerDecorator [](https://travis-ci.org/kouyaf77/eager_decorator) [](http://badge.fury.io/rb/eager_decorator)
|
2
2
|
|
3
3
|
A simple decorator for Rails 3 and Rails 4.
|
4
4
|
Always, the decorator is mixed automatically in model.
|
@@ -20,7 +20,11 @@ $ rails g decorator user
|
|
20
20
|
## Supported versions
|
21
21
|
|
22
22
|
* Ruby 1.9.3, 2.0.0, 2.1.0
|
23
|
-
*
|
23
|
+
* Rails 3.2.0, 4.0.0, 4.1.0, 4.2.0
|
24
|
+
|
25
|
+
## Supported ORMs
|
26
|
+
|
27
|
+
* ActiveRecord
|
24
28
|
|
25
29
|
## Copyright
|
26
30
|
|
data/lib/eager_decorator.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
require "rails"
|
1
2
|
require "eager_decorator/version"
|
2
|
-
require "eager_decorator/
|
3
|
+
require "eager_decorator/hooks"
|
3
4
|
require "eager_decorator/railtie"
|
5
|
+
|
6
|
+
module EagerDecorator
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
class << self
|
11
|
+
def inherited_with_decorator(klass)
|
12
|
+
decorator = "#{klass.name.classify}Decorator".safe_constantize
|
13
|
+
klass.send(:include, decorator) if decorator
|
14
|
+
inherited_without_decorator(klass)
|
15
|
+
end
|
16
|
+
alias_method_chain(:inherited, :decorator)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
class User < ActiveRecord::Base; end
|
data/spec/dummy/config.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eager_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KoyaFukuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple Decorator for Rails
|
14
14
|
email:
|
@@ -30,13 +30,14 @@ files:
|
|
30
30
|
- gemfiles/Gemfile-rails.4.1.x
|
31
31
|
- gemfiles/Gemfile-rails.4.2.x
|
32
32
|
- lib/eager_decorator.rb
|
33
|
-
- lib/eager_decorator/
|
33
|
+
- lib/eager_decorator/hooks.rb
|
34
34
|
- lib/eager_decorator/railtie.rb
|
35
35
|
- lib/eager_decorator/version.rb
|
36
36
|
- lib/generators/rails/decorator_generator.rb
|
37
37
|
- lib/generators/rails/templates/decorator.rb
|
38
38
|
- spec/decorators/user_decorator_spec.rb
|
39
39
|
- spec/dummy/app/decorators/user_decorator.rb
|
40
|
+
- spec/dummy/app/models/user.rb
|
40
41
|
- spec/dummy/config.rb
|
41
42
|
- spec/spec_helper.rb
|
42
43
|
homepage: ''
|
@@ -66,5 +67,6 @@ summary: A simple Decorator for Rails
|
|
66
67
|
test_files:
|
67
68
|
- spec/decorators/user_decorator_spec.rb
|
68
69
|
- spec/dummy/app/decorators/user_decorator.rb
|
70
|
+
- spec/dummy/app/models/user.rb
|
69
71
|
- spec/dummy/config.rb
|
70
72
|
- spec/spec_helper.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "singleton"
|
2
|
-
|
3
|
-
module EagerDecorator
|
4
|
-
class Decorator
|
5
|
-
include Singleton
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
path = "#{Rails.root}/app/decorators/**/*.rb"
|
9
|
-
|
10
|
-
Dir.glob(path).each do |file|
|
11
|
-
model_name = File.basename(file, ".rb").sub(/_decorator/, "")
|
12
|
-
model = model_name.classify.constantize rescue nil
|
13
|
-
unless model.nil?
|
14
|
-
model.send(:include, "#{model_name.classify}Decorator".constantize)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|