defer_draper 0.0.1 → 0.0.3
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/lib/defer_draper/action_controller.rb +27 -0
- data/lib/defer_draper.rb +7 -17
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5154a43854631dc5cc3084d80b3a9f025ef1cfd9
|
|
4
|
+
data.tar.gz: 23f5b8e2b40b15684b0ec7c27ad5abf517c89198
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d0b030a77389274ccb8dcdb9799d7d9bbcc40ffc796599369bf860f4e92ac8a0eb3a92b6c1068515a8195257b7cb24d27d9407ba8f56cf665fdc46b095866ca1
|
|
7
|
+
data.tar.gz: c5409145ff996f40e4e47fa81ac2c60fad43587bf741b0d27c23060639236913fafbb96cdd30435b0fb1d51079db82d966f0616045d2abfdb7180aa31d6c1529
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module ActionController
|
|
2
|
+
class Base
|
|
3
|
+
def render(options = nil, extra_options = {}, &block)
|
|
4
|
+
if self.defer_draper_decorate
|
|
5
|
+
self.instance_variables.select {|variable|
|
|
6
|
+
not variable.to_s.start_with?('@_')
|
|
7
|
+
}.map {|variable_name|
|
|
8
|
+
[variable_name, self.instance_variable_get(variable_name)]
|
|
9
|
+
}.select {|variable_name, variable|
|
|
10
|
+
variable.respond_to?(:decorate)
|
|
11
|
+
}.each {|variable_name, variable|
|
|
12
|
+
begin
|
|
13
|
+
self.instance_variable_set(variable_name, variable.decorate)
|
|
14
|
+
rescue Draper::UninferrableDecoratorError
|
|
15
|
+
;
|
|
16
|
+
end
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
super(options, extra_options, &block)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def defer_draper_decorate
|
|
24
|
+
return false
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/defer_draper.rb
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
class Base
|
|
3
|
-
def render(options = nil, extra_options = {}, &block)
|
|
4
|
-
self.instance_variables.select {|variable|
|
|
5
|
-
not variable.to_s.start_with?('@_')
|
|
6
|
-
}.map {|variable_name|
|
|
7
|
-
[variable_name, self.instance_variable_get(variable_name)]
|
|
8
|
-
}.select {|variable_name, variable|
|
|
9
|
-
variable.respond_to?(:decorate)
|
|
10
|
-
}.each {|variable_name, variable|
|
|
11
|
-
begin
|
|
12
|
-
self.instance_variable_set(variable_name, variable.decorate)
|
|
13
|
-
rescue Draper::UninferrableDecoratorError
|
|
14
|
-
;
|
|
15
|
-
end
|
|
16
|
-
}
|
|
1
|
+
require 'defer_draper/action_controller'
|
|
17
2
|
|
|
18
|
-
|
|
3
|
+
module DeferDraper
|
|
4
|
+
def decorate_all
|
|
5
|
+
def self.defer_draper_decorate
|
|
6
|
+
return true
|
|
19
7
|
end
|
|
20
8
|
end
|
|
21
9
|
end
|
|
10
|
+
|
|
11
|
+
ActionController::Base.send :include, DeferDraper
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: defer_draper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ricardo Franco
|
|
@@ -52,14 +52,15 @@ dependencies:
|
|
|
52
52
|
- - ~>
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '2.12'
|
|
55
|
-
description: Decorate your variables just before render
|
|
55
|
+
description: Decorate all your instance variables just before render
|
|
56
56
|
email: ricardo.krieg@gmail.com
|
|
57
57
|
executables: []
|
|
58
58
|
extensions: []
|
|
59
59
|
extra_rdoc_files: []
|
|
60
60
|
files:
|
|
61
61
|
- lib/defer_draper.rb
|
|
62
|
-
|
|
62
|
+
- lib/defer_draper/action_controller.rb
|
|
63
|
+
homepage: https://github.com/ricardokrieg/defer_draper
|
|
63
64
|
licenses: []
|
|
64
65
|
metadata: {}
|
|
65
66
|
post_install_message:
|
|
@@ -81,5 +82,5 @@ rubyforge_project:
|
|
|
81
82
|
rubygems_version: 2.0.0.rc.2
|
|
82
83
|
signing_key:
|
|
83
84
|
specification_version: 4
|
|
84
|
-
summary:
|
|
85
|
+
summary: Decorate your variables
|
|
85
86
|
test_files: []
|