Sha256: 7537dc01c64d08d9122099467fcf4a4419ebbb1f0e6f8b40393050747d201896
Contents?: true
Size: 653 Bytes
Versions: 8
Compression:
Stored size: 653 Bytes
Contents
module Dragonfly module Generation # HashWithCssStyleKeys is solely for being able to access a hash # which has css-style keys (e.g. 'font-size') with the underscore # symbol version # @example # opts = {'font-size' => '23px', :color => 'white'} # opts = HashWithCssStyleKeys[opts] # opts[:font_size] # ===> '23px' # opts[:color] # ===> 'white' class HashWithCssStyleKeys < Hash def [](key) super || ( str_key = key.to_s css_key = str_key.gsub('_','-') super(str_key) || super(css_key) || super(css_key.to_sym) ) end end end end
Version data entries
8 entries across 8 versions & 2 rubygems