Class: Railsboot::Component

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/railsboot/component.rb

Overview

parent class for all RailsbootUI related components

Constant Summary collapse

COLORS =
["primary", "secondary", "success", "danger", "warning", "info", "light", "dark"].freeze
DEFAULT_COLOR =
"primary".freeze

Instance Method Summary collapse

Instance Method Details

#fetch_or_fallback(argument, constant, fallback) ⇒ Object (protected)



16
17
18
19
20
21
22
# File 'app/components/railsboot/component.rb', line 16

def fetch_or_fallback(argument, constant, fallback)
  if argument.present? && constant.include?(argument.to_s)
    argument
  else
    fallback
  end
end

#fetch_or_raise(argument, constant) ⇒ Object (protected)



8
9
10
11
12
13
14
# File 'app/components/railsboot/component.rb', line 8

def fetch_or_raise(argument, constant)
  if argument.present? && constant.include?(argument.to_s)
    argument
  else
    raise ArgumentError, "The `#{argument}: #{argument}` argument is not valid, allowed options are #{constant.join(", ")}."
  end
end