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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9985de85e2f4c6e1412f1d47f442fcbbbf946764
4
- data.tar.gz: 5c98cd1418bb39fd63c5d19873a9e9cf99d03ce3
3
+ metadata.gz: 40c3bf410755b9dfcb50e51948c367550b1aeb21
4
+ data.tar.gz: 62a3e22b36b742d28eef28b3ef32ea86948e972c
5
5
  SHA512:
6
- metadata.gz: 01671331b1e6ecd71a3bd0b95701df08b6cd059d30d49c192fd72138a908ad973391b1d58027561f44d6366db8bac407cabd076d54d64fa7ed41d78c9808809c
7
- data.tar.gz: f9c9fe0f517cc2cc9e0c5e016eec7928da8801b6a2d553050dccf32bff5f78716f3f7eb767fd7fb699c23689fbde97bde46139289a737356dcbe5336659c07af
6
+ metadata.gz: 7c1e2c5f8a7f220da57b6c9deca25fb12be8598e00cdb213c97acc90a92ac96e32c9939f91bb344e24bbb2fe65f7dd301cc0b946b446978534426d646dd8f8ee
7
+ data.tar.gz: d8c20de6e4bc024ea026c57362431e0a1eee5acea78f95dbdef2e4e25a25e1b18a9d8b7328e46cf027b33d07af9836be36e4750c1a881586eaa13e6e2c55e16d
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ /spec/dummy/log/
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # EagerDecorator [![Build Status](https://travis-ci.org/kouyaf77/eager_decorator.svg)](https://travis-ci.org/kouyaf77/eager_decorator)
1
+ # EagerDecorator [![Build Status](https://travis-ci.org/kouyaf77/eager_decorator.svg)](https://travis-ci.org/kouyaf77/eager_decorator) [![Gem Version](https://badge.fury.io/rb/eager_decorator.svg)](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
- * Ruby 3.2.0, 4.0.0, 4.1.0, 4.2.0
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
 
@@ -1,3 +1,19 @@
1
+ require "rails"
1
2
  require "eager_decorator/version"
2
- require "eager_decorator/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,11 @@
1
+ module EagerDecorator
2
+ class Hooks
3
+ class << self
4
+ def init
5
+ ActiveSupport.on_load(:active_record) do
6
+ ::ActiveRecord::Base.send(:include, EagerDecorator)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,9 +1,7 @@
1
- require "rails"
2
-
3
1
  module EagerDecorator
4
2
  class Railtie < ::Rails::Railtie
5
3
  initializer "eager_decorator" do
6
- EagerDecorator::Decorator.instance
4
+ EagerDecorator::Hooks.init
7
5
  end
8
6
  end
9
7
  end
@@ -1,3 +1,3 @@
1
1
  module EagerDecorator
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1 @@
1
+ class User < ActiveRecord::Base; end
data/spec/dummy/config.rb CHANGED
@@ -2,9 +2,6 @@ require "active_record"
2
2
  require "action_controller/railtie"
3
3
  require "action_view/railtie"
4
4
 
5
- # model
6
- class User < ActiveRecord::Base; end
7
-
8
5
  # migrations
9
6
  class CreateAllTables < ActiveRecord::Migration
10
7
  def self.up
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.1
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-03 00:00:00.000000000 Z
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/decorator.rb
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