Module: HasDomAttrs::ClassMethods
- Defined in:
- lib/has_dom_attrs.rb
Instance Method Summary collapse
- #has_dom_aria(name, value = nil, **options) ⇒ Object
- #has_dom_attr(name, value = nil, **options) ⇒ Object
- #has_dom_class(value, **options) ⇒ Object
- #has_dom_data(name, value = nil, **options) ⇒ Object
- #has_dom_style(name, value = nil, **options) ⇒ Object
Instance Method Details
#has_dom_aria(name, value = nil, **options) ⇒ Object
20 21 22 |
# File 'lib/has_dom_attrs.rb', line 20 def has_dom_aria(name, value = nil, **) prepend___has_dom___method(:dom_aria, name, value, **) end |
#has_dom_attr(name, value = nil, **options) ⇒ Object
16 17 18 |
# File 'lib/has_dom_attrs.rb', line 16 def has_dom_attr(name, value = nil, **) prepend___has_dom___method(:dom_attrs, name, value, **) end |
#has_dom_class(value, **options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/has_dom_attrs.rb', line 28 def has_dom_class(value, **) prepend( Module.new do define_method :dom_classes do cond = [:if] || [:unless] cond_value = case cond when Proc then instance_exec(&cond) when Symbol, String then send(cond) end if cond && .key?(:if) return super() unless cond_value end if cond && .key?(:unless) return super() if cond_value end super().tap do |classes| classes << case value when Proc then instance_exec(&value) when Symbol then send(value) else value end end end end ) end |
#has_dom_data(name, value = nil, **options) ⇒ Object
24 25 26 |
# File 'lib/has_dom_attrs.rb', line 24 def has_dom_data(name, value = nil, **) prepend___has_dom___method(:dom_data, name, value, **) end |
#has_dom_style(name, value = nil, **options) ⇒ Object
58 59 60 |
# File 'lib/has_dom_attrs.rb', line 58 def has_dom_style(name, value = nil, **) prepend___has_dom___method(:dom_style, name, value, **) end |