-
-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
…on, this is arguably better than eval?
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1031,10 +1031,9 @@ def custom_formatter(formatter_ref) | |
formatter_ref | ||
elsif string_const?(formatter_ref) | ||
begin | ||
::Kernel.const_get(formatter_ref) | ||
formatter_ref.scan(/(?:::|^)(\w+)/).flatten.inject(Object) { |const,string| const.const_get string } | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
myronmarston
Member
|
||
rescue NameError | ||
require path_for(formatter_ref) | ||
::Kernel.const_get(formatter_ref) | ||
require( path_for(formatter_ref) ) ? retry : raise | ||
end | ||
end | ||
end | ||
|
1 comment
on commit f8d73a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to comment on this...ruby 2.0 is the first version that allows const_get
to get qualified constants. We should extract our recursive_const_get
logic from rspec-mocks into rspec-support and use that from here:
Why use
scan().flatten
instead of split like I did in the rspec-mocks version of this?