Make LazyObject type-checkable.
This commit is contained in:
parent
9922ad382f
commit
b1000952b1
@ -71,6 +71,10 @@ Layout/HeredocIndentation:
|
||||
Metrics/ParameterLists:
|
||||
CountKeywordArgs: false
|
||||
|
||||
# Allow dashes in filenames.
|
||||
Naming/FileName:
|
||||
Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/
|
||||
|
||||
# Implicitly allow EOS as we use it everywhere.
|
||||
Naming/HeredocDelimiterNaming:
|
||||
ForbiddenDelimiters:
|
||||
@ -80,10 +84,6 @@ Naming/MethodName:
|
||||
IgnoredPatterns:
|
||||
- '\A(fetch_)?HEAD\?\Z'
|
||||
|
||||
# Allow dashes in filenames.
|
||||
Naming/FileName:
|
||||
Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/
|
||||
|
||||
# Both styles are used depending on context,
|
||||
# e.g. `sha256` and `something_countable_1`.
|
||||
Naming/VariableNumber:
|
||||
|
||||
@ -43,7 +43,10 @@ Metrics/ModuleLength:
|
||||
|
||||
Naming/PredicateName:
|
||||
# Can't rename these.
|
||||
AllowedMethods: is_32_bit?, is_64_bit?
|
||||
AllowedMethods:
|
||||
- is_a?
|
||||
- is_32_bit?
|
||||
- is_64_bit?
|
||||
|
||||
Style/HashAsLastArrayItem:
|
||||
Exclude:
|
||||
|
||||
@ -18,4 +18,9 @@ class LazyObject < Delegator
|
||||
def __setobj__(callable)
|
||||
@__callable__ = callable
|
||||
end
|
||||
|
||||
# Forward to the inner object to make lazy objects type-checkable.
|
||||
def is_a?(klass)
|
||||
__getobj__.is_a?(klass) || super
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user