Class: NitroKit::Component
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- NitroKit::Component
- Defined in:
- app/components/nitro_kit/component.rb
Direct Known Subclasses
Accordion, Badge, Button, ButtonGroup, Card, Checkbox, Dropdown, Field, FieldGroup, Fieldset, Icon, Input, Label, RadioButton, RadioGroup, Switch
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
Class Method Summary collapse
Instance Method Summary collapse
- #data_merge(*hashes) ⇒ Object
-
#initialize(**attrs) ⇒ Component
constructor
A new instance of Component.
- #merge(*args) ⇒ Object
Constructor Details
#initialize(**attrs) ⇒ Component
Returns a new instance of Component.
7 8 9 |
# File 'app/components/nitro_kit/component.rb', line 7 def initialize(**attrs) @attrs = attrs.symbolize_keys end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
5 6 7 |
# File 'app/components/nitro_kit/component.rb', line 5 def attrs @attrs end |
Class Method Details
.merge(*args) ⇒ Object
17 18 19 |
# File 'app/components/nitro_kit/component.rb', line 17 def self.merge(*args) Merger.merge(args) end |
Instance Method Details
#data_merge(*hashes) ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/components/nitro_kit/component.rb', line 21 def data_merge(*hashes) hashes.compact.reverse.reduce({}) do |acc, hash| acc.deep_merge(hash) do |_key, old_val, new_val| [old_val, new_val].compact.join(" ") end end end |
#merge(*args) ⇒ Object
13 14 15 |
# File 'app/components/nitro_kit/component.rb', line 13 def merge(*args) self.class.merge(*args) end |