Class: Homebrew::Livecheck::Options Private
- Defined in:
- livecheck/options.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Options to modify livecheck's behavior. These primarily come from
livecheck
blocks but they can also be set by livecheck at runtime.
Option values use a nil
default to indicate that the value has not been
set.
Instance Attribute Summary collapse
-
#homebrew_curl ⇒ Boolean?
private
Whether to use brewed curl.
-
#post_form ⇒ Hash{Symbol => String}?
private
Form data to use when making a
POST
request. -
#post_json ⇒ Hash{Symbol => String}?
private
JSON data to use when making a
POST
request.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
private
Whether the object has only default values.
- #initialize(homebrew_curl: nil, post_form: nil, post_json: nil) ⇒ void constructor
-
#merge(other) ⇒ Options
private
Returns a new object formed by merging
other
values with a copy ofself
. -
#merge!(other) ⇒ Options
private
Merges values from
other
intoself
and returnsself
. -
#present? ⇒ Boolean
private
Whether the object has any non-default values.
-
#to_h ⇒ Hash{Symbol => T.untyped}
private
Returns a
Hash
of all instance variables, usingSymbol
keys. -
#to_hash ⇒ Hash{String => T.untyped}
private
Returns a
Hash
of all instance variables, usingString
keys. -
#url_options ⇒ Hash{Symbol => T.untyped}
private
Returns a
Hash
of options that are provided as arguments tourl
.
Constructor Details
Instance Attribute Details
#homebrew_curl ⇒ Boolean?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Whether to use brewed curl.
|
# File '' prop :homebrew_curl, T.nilable(T::Boolean) |
#post_form ⇒ Hash{Symbol => String}?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Form data to use when making a POST
request.
|
# File '' prop :post_form, T.nilable(T::Hash[Symbol, String]) |
#post_json ⇒ Hash{Symbol => String}?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
JSON data to use when making a POST
request.
|
# File '' prop :post_json, T.nilable(T::Hash[Symbol, String]) |
Instance Method Details
#empty? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Whether the object has only default values.
98 |
# File 'livecheck/options.rb', line 98 def empty? = to_hash.empty? |
#merge(other) ⇒ Options
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a new object formed by merging other
values with a copy of
self
.
nil
values are removed from other
before merging if it is an
Options
object, as these are unitiailized values. This ensures that
existing values in self
aren't unexpectedly overwritten with defaults.
48 49 50 51 52 53 54 55 56 57 |
# File 'livecheck/options.rb', line 48 def merge(other) return dup if other.empty? this_hash = to_h other_hash = other.is_a?(Options) ? other.to_h : other return dup if this_hash == other_hash = this_hash.merge(other_hash) Options.new(**) end |
#merge!(other) ⇒ Options
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Merges values from other
into self
and returns self
.
nil
values are removed from other
before merging if it is an
Options
object, as these are unitiailized values. This ensures that
existing values in self
aren't unexpectedly overwritten with defaults.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'livecheck/options.rb', line 65 def merge!(other) return self if other.empty? if other.is_a?(Options) return self if self == other other.instance_variables.each do |ivar| next if (v = T.let(other.instance_variable_get(ivar), Object)).nil? instance_variable_set(ivar, v) end else other.each do |k, v| cmd = :"#{k}=" send(cmd, v) if respond_to?(cmd) end end self end |
#present? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Whether the object has any non-default values.
102 |
# File 'livecheck/options.rb', line 102 def present? = !empty? |
#to_h ⇒ Hash{Symbol => T.untyped}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a Hash
of all instance variables, using Symbol
keys.
39 |
# File 'livecheck/options.rb', line 39 def to_h = to_hash.transform_keys(&:to_sym) |
#to_hash ⇒ Hash{String => T.untyped}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a Hash
of all instance variables, using String
keys.
33 34 35 |
# File 'livecheck/options.rb', line 33 def to_hash T.let(serialize, T::Hash[String, T.untyped]) end |
#url_options ⇒ Hash{Symbol => T.untyped}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a Hash
of options that are provided as arguments to url
.
23 24 25 26 27 28 29 |
# File 'livecheck/options.rb', line 23 def { homebrew_curl:, post_form:, post_json:, } end |