Module: OpenURI
- Defined in:
- lib/nesta-plugin-contentfocus/openuri_monkeypatch.rb
Class Method Summary collapse
-
.open_uri(name, options = {}) ⇒ Object
The original open_uri takes *args but then doesn’t do anything with them.
- .open_uri_original ⇒ Object
- .redirectable_baller?(uri1, uri2) ⇒ Boolean
Class Method Details
.open_uri(name, options = {}) ⇒ Object
The original open_uri takes *args but then doesn’t do anything with them. Assume we can only handle a hash.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nesta-plugin-contentfocus/openuri_monkeypatch.rb', line 15 def self.open_uri name, = {} value = .delete :allow_unsafe_redirects if value class <<self remove_method :redirectable? alias_method :redirectable?, :redirectable_baller? end else class <<self remove_method :redirectable? alias_method :redirectable?, :redirectable_cautious? end end self.open_uri_original name, end |
.open_uri_original ⇒ Object
4 |
# File 'lib/nesta-plugin-contentfocus/openuri_monkeypatch.rb', line 4 alias_method :open_uri_original, :open_uri |
.redirectable_baller?(uri1, uri2) ⇒ Boolean
7 8 9 10 |
# File 'lib/nesta-plugin-contentfocus/openuri_monkeypatch.rb', line 7 def redirectable_baller? uri1, uri2 valid = /\A(?:https?|ftp)\z/i valid =~ uri1.scheme.downcase && valid =~ uri2.scheme end |