Class: Hamloft::Widget

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/hamloft/widget.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#asset, #asset_uri, #block, #drop_container, #font, #link, #parse_html, #root_asset, #style, #style_string, #var, #variable, #widget_block

Constructor Details

#initialize(options) ⇒ Widget

Returns a new instance of Widget.



14
15
16
# File 'lib/hamloft/widget.rb', line 14

def initialize(options)
  @options = defaults.merge(options)
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/hamloft/widget.rb', line 4

def options
  @options
end

Instance Method Details

#defaultsObject



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

def defaults
  {}
end

#identifierObject



6
7
8
# File 'lib/hamloft/widget.rb', line 6

def identifier
  'base'
end

#typeloft_widget_optionsObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/hamloft/widget.rb', line 18

def typeloft_widget_options
  attributes = {
    :class => '_typeloft_widget',
    :"data-widget-identifier" => identifier
  }
  @options.each do |k, v|
    attributes["data-attribute-#{k}"] = v
  end
  attributes
end