Class: Showcase::Helpers::HtmlOptions
- Inherits:
-
Object
- Object
- Showcase::Helpers::HtmlOptions
- Defined in:
- lib/showcase/helpers/html_options.rb
Instance Method Summary collapse
- #add_class!(css_class) ⇒ Object
-
#initialize(options = {}) ⇒ HtmlOptions
constructor
A new instance of HtmlOptions.
- #merge_attrs!(options = {}) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ HtmlOptions
Returns a new instance of HtmlOptions.
6 7 8 |
# File 'lib/showcase/helpers/html_options.rb', line 6 def initialize( = {}) @options = ( || {}).symbolize_keys end |
Instance Method Details
#add_class!(css_class) ⇒ Object
10 11 12 |
# File 'lib/showcase/helpers/html_options.rb', line 10 def add_class!(css_class) merge_attrs!(class: css_class) end |
#merge_attrs!(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/showcase/helpers/html_options.rb', line 14 def merge_attrs!( = {}) = ( || {}).symbolize_keys if [:class] class_attr = HtmlClassAttribute.new(@options[:class]) class_attr << [:class] [:class] = class_attr.to_html_attribute end @options.merge!() end |
#to_h ⇒ Object
26 27 28 |
# File 'lib/showcase/helpers/html_options.rb', line 26 def to_h @options.dup end |