resque_safe 0.0.3 → 0.0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTUwNmQzNzJmM2QyMjdmMDRjODJlZWZjMGRlMjM5MzJjNWVkMTk0MA==
4
+ ZDk5Yjk2YmY0NjAxMTJlZTU0NWMxY2YxZDUxY2I4OTMxMTc2MmNiMw==
5
5
  data.tar.gz: !binary |-
6
- MjYzY2ZhYzIxMGM1ZTRiYjY2MmRjZTE4NTkzNDBlYTdmOWQ5MzQ2Yw==
6
+ MDIyODhkYjA2YTc0Y2I1M2M1Y2NlZDkyNDhmYWZiMWJiMzhiNGEwYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGFjNGEwYmFhNzRkMDI4NjE5NDQxNzcwZTA1OTExMzUzMjFiODNiN2RhZGIy
10
- ODU4MWI1OTdhNTU4Y2FkYzZlZjFmNWFmYzg3MjEzNmY2MTk4NjhkZTBkNDRl
11
- NWExMTFmOGU2ZjhkMmU0OWVhYWI0ZWM1MDFmYTJhM2MxMDc4YzY=
9
+ NTQzYWVjZTg5ZWVmM2YzYzQ5MWMzNWI0NWU4YTkwNzMwNzViYzNkZGM5OWYy
10
+ ZmRiMjE5ZWYxN2YxNzgzNTEyZDE4YmQzYjgxZDAxYzk1NTM3OGNhMGQ5ZTJl
11
+ M2QwMWY2ZWY2MGZlOTIyYWI2MTFmMTQ1OTY0Zjg5NzczYmVkYTM=
12
12
  data.tar.gz: !binary |-
13
- YTc4ZGQ3ZDQ5Yzc3NDlmMjE5NDI4YTJjZjk0ZTM5NmZkNDYzNzMxNDU3MWU5
14
- NmUwMDI0YmExZTMwMjkzMDUwMzZkODJjNTNlZGFlMzAyM2E5ZDBmNDVhOWNh
15
- YzUzMWRmZWJhODIzZjE2YThjNDQ3ZWY2OGM2Njk4MDE1NDc1MDY=
13
+ OGFlZDIzMjkyYzI5ZGU0MDA4NDQwODA0MTUxOGQ3ZDA2ZjRmNmJmYzBlNGUx
14
+ OTdjNDQ2ZTY5M2U3YmVhYjI5NDliNTNmMjUxZWIyODMzMmE3ZWZlZjBkNDBi
15
+ ZDJhMTVmODA4MzU0MDRkNDAwOWMwY2U1ODg4NDIyZDc5YzBhOTI=
@@ -1,6 +1,9 @@
1
+
1
2
  module ResqueSafe
2
3
  module ConvertFromHash
3
- def to_objects(inbound_hash)
4
+ def args_to_objects(inbound_hash)
5
+ raise NotImplementedError.new "This isn't completed, not sure how to set it up"
6
+
4
7
  objects = {}
5
8
  inbound_hash.each do |klass_name,value|
6
9
  klass_name, value = klass_name.to_s, value.to_s
@@ -37,30 +40,60 @@ module ResqueSafe
37
40
  end
38
41
  end
39
42
 
43
+ def set_instance_args_for_class(mailer_instance, args)
44
+ #take each key, if a model, make it an @#{model} = model.find(value)
45
+ #else make it a @#{name}=#{value}
46
+
47
+ args.each do |klass_name,value|
48
+ klass_name, value = klass_name.to_s, value.to_s
49
+ klassified_klass = klass_name.classify
50
+
51
+ if Object.const_defined?(klassified_klass) &&
52
+ known_models.include?(klassified_klass.constantize)
53
+
54
+ set_instance_for_active_record_mailer_instance(mailer_instance, klassified_klass, value)
55
+ else
56
+ set_instance_for_other_mialer_instance(mailer_instance, klass_name, value)
57
+ end
58
+ end
59
+ end
60
+
40
61
  private
41
- def return_active_record(klass_name, value)
42
- return self.instance_eval("#{klass_name.constantize}.find(#{value})")
62
+ def set_instance_for_active_record(klass_name, value)
63
+ set_instance_for_active_record_mailer_instance(self, klass_name, value)
43
64
  end
44
65
 
45
- def return_other_object(klass_name, value)
66
+ def set_instance_for_active_record_mailer_instance(mailer_instance, klass_name, value)
67
+ mailer_instance.instance_eval("@#{klass_name.downcase}= #{klass_name.constantize}.find(#{value})")
68
+ end
69
+
70
+ def set_instance_for_other(instance_name, value)
71
+ set_instance_for_other_mialer_instance(self, instance_name, value)
72
+ end
73
+
74
+
75
+ def set_instance_for_other_mialer_instance(mailer_instance, instance_name, value)
46
76
  if value.is_a?(String)
47
- return self.instance_eval("%|#{value}|")
77
+ mailer_instance.instance_eval("@#{instance_name} = %|#{value}|")
48
78
  else
49
- return self.instance_eval(":#{instance_name} => #{value}")
79
+ mailer_instance.instance_eval("@#{instance_name}=#{value}")
50
80
  end
51
-
52
81
  end
53
82
 
54
- def set_instance_for_active_record(klass_name, value)
55
- self.instance_eval("@#{klass_name}= #{klass_name.constantize}.find(#{value})")
83
+ def return_active_record(klass_name, value)
84
+ raise NotImplementedError.new "This isn't completed, not sure how to set it up"
85
+ return self.instance_eval("#{klass_name.constantize}.find(#{value})")
56
86
  end
57
87
 
58
- def set_instance_for_other(instance_name, value)
88
+ def return_other_object(klass_name, value)
89
+ raise NotImplementedError.new "This isn't completed, not sure how to set it up"
59
90
  if value.is_a?(String)
60
- self.instance_eval("@#{instance_name} = %|#{value}|")
91
+ return self.instance_eval("%|#{value}|")
61
92
  else
62
- self.instance_eval("@#{instance_name}=#{value}")
93
+ return self.instance_eval(":#{instance_name} => #{value}")
63
94
  end
95
+
64
96
  end
97
+
65
98
  end
66
99
  end
@@ -5,7 +5,7 @@ module ResqueSafe
5
5
 
6
6
  args = args.flatten if args.respond_to?(:flatten)
7
7
 
8
- args.each do |arg|
8
+ args.each do |arg, index|
9
9
  next if arg.blank?
10
10
  arg_class = arg.class.name
11
11
  if arg.is_a?(Hash)
@@ -18,6 +18,8 @@ module ResqueSafe
18
18
  end
19
19
  elsif known_models.include?(arg_class) || arg.class.respond_to?(:column_names)
20
20
  th[arg_class.underscore.to_sym] = arg.id
21
+ elsif arg.is_a?(String)
22
+ th[index] = v
21
23
  else
22
24
  raise ArgumentError.new("Unknown #{arg_class} passed to resque safe. \n Object #{arg.inspect} \n\n Args #{args} \n\n Known Models #{known_models}")
23
25
  end
data/lib/resque_safe.rb CHANGED
@@ -3,7 +3,8 @@ require 'resque_safe/convert_from_hash'
3
3
  require 'resque_safe/util'
4
4
 
5
5
  module ResqueSafe
6
- extend Util
7
- extend ConvertFromHash
8
- extend ConvertToHash
6
+ extend ResqueSafe::Util
7
+ extend ResqueSafe::ConvertFromHash
8
+ extend ResqueSafe::ConvertToHash
9
9
  end
10
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_safe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert R. Meyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport