autoload_resources 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/autoload_resources/able.rb +13 -6
- data/lib/autoload_resources/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21bed64325a6b9eefc9df6a89f1cfb3ecf3e5a9b
|
4
|
+
data.tar.gz: ed47fd0f9880ea564a155d962c54bd27092dfe5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21a72f3ad372a6284846fbefcde80c7be36f47f49462ea470904b8c8650b59b6577bfce8568c1f3c1600bbcb1482fe82b59686b52b09c6fbde8edd00d9a0ec19
|
7
|
+
data.tar.gz: 7275b7292be0eb6cb4420b9be42301be1b868def9ecd88583b396174304a8729e96abae72af1b4531ea6f21c7ba1e5efa3aadf7454709434e1094afc6ba0ddc0
|
@@ -4,10 +4,11 @@ module AutoloadResources
|
|
4
4
|
|
5
5
|
def autoload_resources(action_name=params[:action])
|
6
6
|
return unless self.class.autoload_procs[action_name]
|
7
|
+
value = instance_eval(&(self.class.autoload_procs[action_name]))
|
7
8
|
self.class.autoload_instance_variable_names(action_name).each do |instance_variable_name|
|
8
9
|
instance_variable_set(
|
9
10
|
"@#{instance_variable_name}",
|
10
|
-
|
11
|
+
value
|
11
12
|
)
|
12
13
|
end
|
13
14
|
end
|
@@ -57,11 +58,7 @@ module AutoloadResources
|
|
57
58
|
|
58
59
|
def default_create_proc
|
59
60
|
Proc.new do
|
60
|
-
|
61
|
-
self.respond_to? "#{name}_params"
|
62
|
-
end
|
63
|
-
return unless params_method
|
64
|
-
resource_class.new(send(params_method))
|
61
|
+
create_params_method and resource_class.new(send(create_params_method))
|
65
62
|
end
|
66
63
|
end
|
67
64
|
|
@@ -73,5 +70,15 @@ module AutoloadResources
|
|
73
70
|
alias_method :for_action, :for_actions
|
74
71
|
|
75
72
|
end
|
73
|
+
|
74
|
+
private
|
75
|
+
def create_params_method
|
76
|
+
self.class.autoload_instance_variable_names(:create).collect do |element|
|
77
|
+
element + "_params"
|
78
|
+
end.find do |params_method_name|
|
79
|
+
self.respond_to? params_method_name
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
76
83
|
end
|
77
84
|
end
|