Make FromContentLoader.try_new typesafe
This commit is contained in:
parent
d40e1707f2
commit
a41f15ede7
@ -51,10 +51,14 @@ module Cask
|
|||||||
|
|
||||||
# Loads a cask from a string.
|
# Loads a cask from a string.
|
||||||
class FromContentLoader < AbstractContentLoader
|
class FromContentLoader < AbstractContentLoader
|
||||||
|
sig {
|
||||||
|
params(ref: T.any(Pathname, String, URI::Generic), warn: T::Boolean)
|
||||||
|
.returns(T.nilable(T.attached_class))
|
||||||
|
}
|
||||||
def self.try_new(ref, warn: false)
|
def self.try_new(ref, warn: false)
|
||||||
return false unless ref.respond_to?(:to_str)
|
return if ref.is_a?(URI::Generic)
|
||||||
|
|
||||||
content = T.unsafe(ref).to_str
|
content = ref.to_str
|
||||||
|
|
||||||
# Cache compiled regex
|
# Cache compiled regex
|
||||||
@regex ||= begin
|
@regex ||= begin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user