Class: Journeybook::ComponentRegistry::Component
- Inherits:
-
Data
- Object
- Data
- Journeybook::ComponentRegistry::Component
- Defined in:
- lib/journeybook/component_registry.rb
Constant Summary collapse
- DEFAULT_PROP_TYPE =
:short_text
Instance Attribute Summary collapse
-
#component_class ⇒ Object
readonly
Returns the value of attribute component_class.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
Instance Attribute Details
#component_class ⇒ Object (readonly)
Returns the value of attribute component_class
3 4 5 |
# File 'lib/journeybook/component_registry.rb', line 3 def component_class @component_class end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
3 4 5 |
# File 'lib/journeybook/component_registry.rb', line 3 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name
3 4 5 |
# File 'lib/journeybook/component_registry.rb', line 3 def name @name end |
Instance Method Details
#normalized_props ⇒ Object
31 32 33 34 35 |
# File 'lib/journeybook/component_registry.rb', line 31 def normalized_props .fetch(:props, {}).each_with_object({}) do |(prop_name, config), props| props[prop_name.to_sym] = normalize_prop(prop_name, config) end end |
#schema ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/journeybook/component_registry.rb', line 6 def schema { "name" => name.to_s, "description" => .fetch(:description, nil), "props" => normalized_props.transform_keys(&:to_s).transform_values do |prop| { "type" => prop[:type].to_s, "label" => prop[:label], "description" => prop[:description], "required" => prop[:required] }.tap do |schema| next unless prop[:type] == :collection schema["min"] = prop[:min] schema["max"] = prop[:max] schema["item"] = prop[:item].transform_keys(&:to_s) end.tap do |schema| next unless prop[:type] == :select schema["options"] = prop[:options] end end } end |