Module: Ariadne::IconHelper
Overview
Constant Summary
FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE
Class Method Summary
collapse
Instance Method Summary
collapse
#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_fallback, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer
#logger, #silence_deprecations?, #silence_warnings?
Class Method Details
.ensure_valid_variant(variant) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'app/lib/ariadne/icon_helper.rb', line 24
def ensure_valid_variant(variant)
check_variant = if variant.blank? || !variant.respond_to?(:to_s)
""
else
variant.to_s
end
fetch_or_raise(HeroiconsHelper::Icon::VALID_VARIANTS, check_variant)
end
|
Instance Method Details
#check_icon_presence!(icon, variant) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'app/lib/ariadne/icon_helper.rb', line 14
def check_icon_presence!(icon, variant)
return true unless has_partial_icon?(icon, variant)
icon_presence!(icon, variant)
variant_presence!(icon, variant)
ensure_valid_variant(variant)
true
end
|
#has_partial_icon?(icon, variant) ⇒ Boolean
35
36
37
|
# File 'app/lib/ariadne/icon_helper.rb', line 35
def has_partial_icon?(icon, variant)
icon.present? || variant.present?
end
|
#icon_presence!(icon, variant) ⇒ Object
39
40
41
42
43
|
# File 'app/lib/ariadne/icon_helper.rb', line 39
def icon_presence!(icon, variant)
raise(ArgumentError, "You must provide an `icon` when providing a `variant`.") if icon.blank? && variant.present?
true
end
|
#variant_presence!(icon, variant) ⇒ Object
45
46
47
48
49
|
# File 'app/lib/ariadne/icon_helper.rb', line 45
def variant_presence!(icon, variant)
raise(ArgumentError, "You must provide a `variant` when providing an `icon`.") if icon.present? && variant.blank?
true
end
|