Class: GenerativeUI::Component
- Inherits:
-
Data
- Object
- Data
- GenerativeUI::Component
- Defined in:
- lib/generative_ui/component.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes
4 5 6 |
# File 'lib/generative_ui/component.rb', line 4 def attributes @attributes end |
#id ⇒ Object (readonly)
Returns the value of attribute id
4 5 6 |
# File 'lib/generative_ui/component.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name
4 5 6 |
# File 'lib/generative_ui/component.rb', line 4 def name @name end |
Class Method Details
.from_raw(raw) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/generative_ui/component.rb', line 5 def self.from_raw(raw) raw = {} unless raw.is_a?(Hash) id = raw["id"] || raw[:id] name = raw["component"] || raw[:component] attributes = raw.each_with_object({}) do |(key, value), memo| next if %w[id component].include?(key.to_s) memo[key.to_s] = value end new(id:, name:, attributes:) end |
Instance Method Details
#to_h ⇒ Object
18 19 20 |
# File 'lib/generative_ui/component.rb', line 18 def to_h { "id" => id, "component" => name, **attributes } end |