rogerdpack-arguments 0.4.7.5 → 0.4.7.6
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.
- data/lib/arguments/class.rb +10 -1
- metadata +1 -1
data/lib/arguments/class.rb
CHANGED
@@ -39,7 +39,8 @@ module NamedArgs
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
line_loc = __LINE__
|
43
|
+
new_code = <<-RUBY_EVAL
|
43
44
|
def __new_#{ meth } *args, &block
|
44
45
|
opts = args.last.kind_of?( Hash ) ? args.pop : {}
|
45
46
|
#{ assigns.join("\n") }
|
@@ -49,6 +50,14 @@ module NamedArgs
|
|
49
50
|
alias __original_#{ meth } #{ meth }
|
50
51
|
alias #{ meth } __new_#{ meth }
|
51
52
|
RUBY_EVAL
|
53
|
+
|
54
|
+
begin
|
55
|
+
klass.module_eval new_code, __FILE__, line_loc + 1
|
56
|
+
rescue SyntaxError => e
|
57
|
+
puts "warning--unable to wrap method #{ meth } -- possibly a syntax exception or it's not all on one line in 1.9 -- #{new_code}"
|
58
|
+
throw e
|
59
|
+
end
|
60
|
+
|
52
61
|
end
|
53
62
|
end
|
54
63
|
|