autoload_resources 0.0.4 → 0.0.5

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: e333dbcf25a499ea194e980a6d39e53bf2b2ef3f
4
- data.tar.gz: d79573a5097d434f9583af3046e213cc10884947
3
+ metadata.gz: 21bed64325a6b9eefc9df6a89f1cfb3ecf3e5a9b
4
+ data.tar.gz: ed47fd0f9880ea564a155d962c54bd27092dfe5d
5
5
  SHA512:
6
- metadata.gz: 0940f3a9c5dba0e015aece367191c7beb57189047c8573c3d6e9880f0c0111a7bb3c294c695b2a74821c9a2dcb44dedb85420574a14f950219d577966a56b40e
7
- data.tar.gz: 73d9165426ef0201a05e9c40a2399f6c86243f2d921c0a21be284ee89425ba255e55804581adf8faecb28660a02bfa84b1f11bf5256d0273bdfaca7e160baae1
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
- instance_eval(&(self.class.autoload_procs[action_name]))
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
- params_method = autoload_instance_variable_names(:create).find do |name|
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
@@ -1,3 +1,3 @@
1
1
  module AutoloadResources
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoload_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - barelyknown