Sha256: f74cffd5181afa2f32c1f69ee96f77557e232c7b566c54fb71e10606cfc3e61c

Contents?: true

Size: 591 Bytes

Versions: 83

Compression:

Stored size: 591 Bytes

Contents

module Dragonfly
  
  # 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

Version data entries

83 entries across 83 versions & 3 rubygems

Version Path
dragonfly-1.0.5 lib/dragonfly/hash_with_css_style_keys.rb
dragonfly-1.0.4 lib/dragonfly/hash_with_css_style_keys.rb
dragonfly-1.0.3 lib/dragonfly/hash_with_css_style_keys.rb
dragonfly-1.0.2 lib/dragonfly/hash_with_css_style_keys.rb
dragonfly-1.0.1 lib/dragonfly/hash_with_css_style_keys.rb
dragonfly-1.0 lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.7.2 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.7.1 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.7.0 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
dragonfly-0.9.15 lib/dragonfly/hash_with_css_style_keys.rb
dragonfly-0.9.14 lib/dragonfly/hash_with_css_style_keys.rb
dragonfly-0.9.13 lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.6.9 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.6.8 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.6.7 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.6.6 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.6.5 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.6.4 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.6.3 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb
classiccms-0.6.2 vendor/bundle/gems/dragonfly-0.9.12/lib/dragonfly/hash_with_css_style_keys.rb