Merge pull request #16305 from Bo98/pour_bottle-api
Partially support `pour_bottle?` in API
This commit is contained in:
commit
8b984114b1
@ -2235,6 +2235,7 @@ class Formula
|
|||||||
"revision" => revision,
|
"revision" => revision,
|
||||||
"version_scheme" => version_scheme,
|
"version_scheme" => version_scheme,
|
||||||
"bottle" => {},
|
"bottle" => {},
|
||||||
|
"pour_bottle_only_if" => self.class.pour_bottle_only_if&.to_s,
|
||||||
"keg_only" => keg_only?,
|
"keg_only" => keg_only?,
|
||||||
"keg_only_reason" => keg_only_reason&.to_hash,
|
"keg_only_reason" => keg_only_reason&.to_hash,
|
||||||
"options" => [],
|
"options" => [],
|
||||||
@ -3538,6 +3539,7 @@ class Formula
|
|||||||
# <pre>pour_bottle? only_if: :clt_installed</pre>
|
# <pre>pour_bottle? only_if: :clt_installed</pre>
|
||||||
def pour_bottle?(only_if: nil, &block)
|
def pour_bottle?(only_if: nil, &block)
|
||||||
@pour_bottle_check = PourBottleCheck.new(self)
|
@pour_bottle_check = PourBottleCheck.new(self)
|
||||||
|
@pour_bottle_only_if = only_if
|
||||||
|
|
||||||
if only_if.present? && block.present?
|
if only_if.present? && block.present?
|
||||||
raise ArgumentError, "Do not pass both a preset condition and a block to `pour_bottle?`"
|
raise ArgumentError, "Do not pass both a preset condition and a block to `pour_bottle?`"
|
||||||
@ -3571,6 +3573,9 @@ class Formula
|
|||||||
@pour_bottle_check.instance_eval(&block)
|
@pour_bottle_check.instance_eval(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
attr_reader :pour_bottle_only_if
|
||||||
|
|
||||||
# Deprecates a {Formula} (on the given date) so a warning is
|
# Deprecates a {Formula} (on the given date) so a warning is
|
||||||
# shown on each installation. If the date has not yet passed the formula
|
# shown on each installation. If the date has not yet passed the formula
|
||||||
# will not be deprecated.
|
# will not be deprecated.
|
||||||
|
|||||||
@ -291,6 +291,10 @@ module Formulary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (pour_bottle_only_if = json_formula["pour_bottle_only_if"])
|
||||||
|
pour_bottle? only_if: pour_bottle_only_if.to_sym
|
||||||
|
end
|
||||||
|
|
||||||
if (keg_only_reason = json_formula["keg_only_reason"].presence)
|
if (keg_only_reason = json_formula["keg_only_reason"].presence)
|
||||||
reason = Formulary.convert_to_string_or_symbol keg_only_reason["reason"]
|
reason = Formulary.convert_to_string_or_symbol keg_only_reason["reason"]
|
||||||
keg_only reason, keg_only_reason["explanation"]
|
keg_only reason, keg_only_reason["explanation"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user