Class: Spark::Component::TagAttr
- Inherits:
-
Attr
- Object
- Hash
- Attr
- Spark::Component::TagAttr
show all
- Defined in:
- lib/spark/component/tag_attr.rb
Instance Method Summary
collapse
Methods inherited from Attr
#initialize, #to_s
Instance Method Details
#add(hash) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/spark/component/tag_attr.rb', line 9
def add(hash)
return self if hash.nil? || hash.keys.empty?
deep_compact!(hash)
= {
aria: hash.delete(:aria),
data: hash.delete(:data),
classname: hash.delete(:class)
}
.each do |method, val|
send(method).add(val) unless val.nil? || val.empty?
end
add(hash.delete(:html))
super(hash)
end
|
#aria(*args) ⇒ Object
33
34
35
|
# File 'lib/spark/component/tag_attr.rb', line 33
def aria(*args)
self[:aria] ||= Component::Attr.new(*args, prefix: :aria)
end
|
#classname(*args, base: nil) ⇒ Object
41
42
43
|
# File 'lib/spark/component/tag_attr.rb', line 41
def classname(*args, base: nil)
self[:class] ||= Component::Classname.new(*args, base: base)
end
|
#data(*args) ⇒ Object
37
38
39
|
# File 'lib/spark/component/tag_attr.rb', line 37
def data(*args)
self[:data] ||= Component::Attr.new(*args, prefix: :data)
end
|