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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f870769ae50c5f4571cee9e4a44b438211756c8e
|
4
|
+
data.tar.gz: a291ca111aec23729d39e1ae8da6f88c60e3501f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 010af5e16b13e68659d193abc4853de32bbaf21991852efe242455300c33b925222939f53e38493ca4bfb671f9f2e7017ba15b886783733575e5fb94e8cc72fa
|
7
|
+
data.tar.gz: 65f67f417bc8f6aafaae79b256f1e6cfb6548e09add4b362a812a7fbc7f2d28310371d66d86e0348f026ffe80e67507f041d23c184da8a3ceb1a7360a47559b2
|
data/lib/deckorator.rb
CHANGED
@@ -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)
|
data/lib/deckorator/delegator.rb
CHANGED
@@ -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
|
data/lib/deckorator/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
<% module_namespacing do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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 %>
|
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
|
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:
|
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:
|
131
|
+
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.4.
|
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:
|