Module: HasDomAttrs

Defined in:
lib/has_dom_attrs.rb,
lib/has_dom_attrs/version.rb

Defined Under Namespace

Modules: ClassMethods Classes: DomStyle

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
# File 'lib/has_dom_attrs.rb', line 10

def included(base)
  base.extend ClassMethods
end

Instance Method Details

#dom_ariaObject



109
110
111
# File 'lib/has_dom_attrs.rb', line 109

def dom_aria
  {}
end

#dom_attrsObject



94
95
96
97
98
99
100
101
102
103
# File 'lib/has_dom_attrs.rb', line 94

def dom_attrs
  {
    aria: dom_aria,
    class: dom_classes,
    data: dom_data,
    style: dom_style.to_s
  }.reject { |_, v| v.nil? || v.empty? }
    .deep_stringify_keys
    .deep_transform_keys(&:dasherize)
end

#dom_classesObject



105
106
107
# File 'lib/has_dom_attrs.rb', line 105

def dom_classes
  []
end

#dom_dataObject



113
114
115
# File 'lib/has_dom_attrs.rb', line 113

def dom_data
  {}
end

#dom_styleObject



117
118
119
# File 'lib/has_dom_attrs.rb', line 117

def dom_style
  DomStyle.new({})
end