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 =

Colors.

%w[primary secondary success danger warning info light dark].freeze
DEFAULT_COLOR =

Default color.

"primary".freeze

Instance Method Summary collapse

Instance Method Details

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



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

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)

Raises:

  • (ArgumentError)


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

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

  argument
end