Replace usage of DelegateClass
with SimpleDelegator
.
This commit is contained in:
parent
f27d7a21d7
commit
17544fc275
@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "delegate"
|
||||
|
||||
require "extend/hash_validator"
|
||||
using HashValidator
|
||||
|
||||
@ -8,7 +10,7 @@ module Cask
|
||||
# Class corresponding to the `conflicts_with` stanza.
|
||||
#
|
||||
# @api private
|
||||
class ConflictsWith < DelegateClass(Hash)
|
||||
class ConflictsWith < SimpleDelegator
|
||||
VALID_KEYS = [
|
||||
:formula,
|
||||
:cask,
|
||||
@ -18,12 +20,13 @@ module Cask
|
||||
:java,
|
||||
].freeze
|
||||
|
||||
def initialize(**pairs)
|
||||
pairs.assert_valid_keys!(*VALID_KEYS)
|
||||
def initialize(**options)
|
||||
options.assert_valid_keys!(*VALID_KEYS)
|
||||
|
||||
super(pairs.transform_values { |v| Set.new(Array(v)) })
|
||||
conflicts = options.transform_values { |v| Set.new(Array(v)) }
|
||||
conflicts.default = Set.new
|
||||
|
||||
self.default = Set.new
|
||||
super(conflicts)
|
||||
end
|
||||
|
||||
def to_json(generator)
|
||||
|
@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "delegate"
|
||||
|
||||
require "requirements/macos_requirement"
|
||||
|
||||
module Cask
|
||||
@ -7,7 +9,7 @@ module Cask
|
||||
# Class corresponding to the `depends_on` stanza.
|
||||
#
|
||||
# @api private
|
||||
class DependsOn < DelegateClass(Hash)
|
||||
class DependsOn < SimpleDelegator
|
||||
VALID_KEYS = Set.new([
|
||||
:formula,
|
||||
:cask,
|
||||
|
@ -6,7 +6,7 @@ require "cask_dependent"
|
||||
# A collection of dependencies.
|
||||
#
|
||||
# @api private
|
||||
class Dependencies < DelegateClass(Array)
|
||||
class Dependencies < SimpleDelegator
|
||||
def initialize(*args)
|
||||
super(args)
|
||||
end
|
||||
@ -41,7 +41,7 @@ end
|
||||
# A collection of requirements.
|
||||
#
|
||||
# @api private
|
||||
class Requirements < DelegateClass(Set)
|
||||
class Requirements < SimpleDelegator
|
||||
def initialize(*args)
|
||||
super(Set.new(args))
|
||||
end
|
||||
|
@ -1,9 +1,11 @@
|
||||
# typed: strict
|
||||
|
||||
class User < String
|
||||
def gui?
|
||||
end
|
||||
class User < SimpleDelegator
|
||||
include Kernel
|
||||
|
||||
def self.current
|
||||
end
|
||||
sig { returns(T::Boolean) }
|
||||
def gui?; end
|
||||
|
||||
sig { returns(T.nilable(T.attached_class)) }
|
||||
def self.current; end
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ require "system_command"
|
||||
# A system user.
|
||||
#
|
||||
# @api private
|
||||
class User < DelegateClass(String)
|
||||
class User < SimpleDelegator
|
||||
# Return whether the user has an active GUI session.
|
||||
def gui?
|
||||
out, _, status = system_command "who"
|
||||
|
Loading…
x
Reference in New Issue
Block a user