deckorator 0.1.0.beta2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b0343623701233233564f457546a863fa96a509
4
- data.tar.gz: 668824755e7e8c53d9f36492665e392d780603f6
3
+ metadata.gz: f870769ae50c5f4571cee9e4a44b438211756c8e
4
+ data.tar.gz: a291ca111aec23729d39e1ae8da6f88c60e3501f
5
5
  SHA512:
6
- metadata.gz: 9d24259f96ac1410059686e39ff1b4f02ca22c5e55e89beb5be29f8243fc2289d74327f1022eb959436c7e4208ccd0ae08c6bec4e39278904c5852b1e644af9a
7
- data.tar.gz: a701fbec40da21937d1b5057890ddacca14d5ec8e7c11321ddf53f734c2b87b87924a309d61c70262e3dfdde70dab761b6bb49a051cd6bb03d2fda43f7f4987a
6
+ metadata.gz: 010af5e16b13e68659d193abc4853de32bbaf21991852efe242455300c33b925222939f53e38493ca4bfb671f9f2e7017ba15b886783733575e5fb94e8cc72fa
7
+ data.tar.gz: 65f67f417bc8f6aafaae79b256f1e6cfb6548e09add4b362a812a7fbc7f2d28310371d66d86e0348f026ffe80e67507f041d23c184da8a3ceb1a7360a47559b2
@@ -1,8 +1,11 @@
1
1
  require 'deckorator/version'
2
2
  require 'deckorator/delegator'
3
3
  require 'deckorator/finder'
4
+ require 'active_support/concern'
4
5
 
5
6
  module Deckorator
7
+ extend ActiveSupport::Concern
8
+
6
9
  class << self
7
10
  def decorate(record)
8
11
  if record.kind_of?(Array) || record.respond_to?(:all)
@@ -17,6 +20,15 @@ module Deckorator
17
20
  end
18
21
  end
19
22
 
23
+ included do
24
+ helper_method :decorate if respond_to?(:helper_method)
25
+ hide_action :decorate if respond_to?(:hide_action)
26
+ end
27
+
28
+ def decorate(record)
29
+ Deckorator.decorate(record)
30
+ end
31
+
20
32
  private
21
33
 
22
34
  def self.decorate_object(record)
@@ -1,9 +1,21 @@
1
+ require 'active_support/concern'
2
+
1
3
  module Deckorator
2
4
  module Delegator
5
+ extend ActiveSupport::Concern
6
+
3
7
  def method_missing(method, *args, &block)
4
8
  decorated_object.respond_to?(method) ?
5
9
  decorated_object.send(method, *args, &block) :
6
10
  super
7
11
  end
12
+
13
+ module ClassMethods
14
+ def method_missing(method, *args, &block)
15
+ decorated_object_class.respond_to?(method) ?
16
+ decorated_object_class.send(method, *args, &block) :
17
+ super
18
+ end
19
+ end
8
20
  end
9
21
  end
@@ -1,3 +1,3 @@
1
1
  module Deckorator
2
- VERSION = '0.1.0.beta2'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -1,9 +1,9 @@
1
- <% module_namespacing do %>
2
- class <%= class_name %>Decorator < ApplicationDecorator
3
- # Here you can add decorator logic to pretty up your views
4
- #
5
- # def full_name
6
- # "#{first_name} #{last_name}".strip
7
- # end
8
- end
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %>Decorator < ApplicationDecorator
3
+ # Here you can add decorator logic to pretty up your views
4
+ #
5
+ # def full_name
6
+ # "#{first_name} #{last_name}".strip
7
+ # end
8
+ end
9
9
  <% end %>
@@ -2,8 +2,10 @@ class ApplicationDecorator
2
2
  include Deckorator::Delegator
3
3
 
4
4
  attr_accessor :decorated_object
5
+ cattr_accessor :decorated_object_class
5
6
 
6
7
  def initialize(object)
7
8
  @decorated_object = object
9
+ self.class.decorated_object_class = object.class
8
10
  end
9
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deckorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Otander
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-12-30 00:00:00.000000000 Z
12
+ date: 2016-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -126,13 +126,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 1.3.1
131
+ version: '0'
132
132
  requirements: []
133
133
  rubyforge_project:
134
- rubygems_version: 2.4.5.1
134
+ rubygems_version: 2.4.3
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Lightweight decorators using plain old Ruby objects.
138
138
  test_files: []
139
+ has_rdoc: