Class: Ariadne::ViewComponents::Constants

Inherits:
Object
  • Object
show all
Defined in:
lib/ariadne/view_components/constants.rb

Overview

A module for constants that are used in the view components.

Constant Summary collapse

CONSTANTS =
JSON.parse(
  File.read(
    File.join(File.dirname(__FILE__), "../../../static/constants.json"),
  ),
).freeze

Class Method Summary collapse

Class Method Details

.get(component:, constant:, invert: true, symbolize: false) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ariadne/view_components/constants.rb', line 16

def get(component:, constant:, invert: true, symbolize: false)
  values = CONSTANTS.dig(component, constant)

  case values
  when Hash
    format_hash(values, invert, symbolize)
  when Array
    format_array(values, symbolize)
  else
    values
  end
end