Class: NitroKit::Component

Inherits:
Phlex::HTML
  • Object
show all
Defined in:
app/components/nitro_kit/component.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#attrsObject (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