Class: Hash

### Home Classes Methods

### In Files

- lib/jekyll/core_ext.rb

### Parent

Object

### Methods

- #deep_merge
- #pluralized_array
- #symbolize_keys
- #symbolize_keys!

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Jekyll
- Jekyll::Command
- Jekyll::Commands
- Jekyll::Commands::Build
- Jekyll::Commands::Doctor
- Jekyll::Commands::New
- Jekyll::Commands::Serve
- Jekyll::Configuration
- Jekyll::Converter
- Jekyll::Converters
- Jekyll::Converters::Identity
- Jekyll::Converters::Markdown
- Jekyll::Converters::Markdown::KramdownParser
- Jekyll::Converters::Markdown::MarukuParser
- Jekyll::Converters::Markdown::RDiscountParser
- Jekyll::Converters::Markdown::RedcarpetParser
- Jekyll::Converters::Markdown::RedcarpetParser::CommonMethods
- Jekyll::Converters::Markdown::RedcarpetParser::WithPygments
- Jekyll::Converters::Markdown::RedcarpetParser::WithoutPygments
- Jekyll::Converters::Textile
- Jekyll::Convertible
- Jekyll::Deprecator
- Jekyll::Draft
- Jekyll::Excerpt
- Jekyll::FatalException
- Jekyll::Filters
- Jekyll::Generator
- Jekyll::Generators
- Jekyll::Generators::Pagination
- Jekyll::GistTag
- Jekyll::Layout
- Jekyll::Page
- Jekyll::Pager
- Jekyll::Plugin
- Jekyll::Post
- Jekyll::RelatedPosts
- Jekyll::Site
- Jekyll::Site::Cleaner
- Jekyll::StaticFile
- Jekyll::Stevenson
- Jekyll::Tags
- Jekyll::Tags::HighlightBlock
- Jekyll::Tags::IncludeTag
- Jekyll::Tags::PostComparer
- Jekyll::Tags::PostUrl
- Jekyll::URL
- Date
- Enumerable
- Hash
- Object

No matching classes.

# Hash

### Public Instance Methods

deep_merge(hash) click to toggle source

Merges self with another hash, recursively.

This code was lovingly stolen from some random gem: gemjack.com/gems/tartan-0.1.1/classes/Hash.html

Thanks to whoever made it.

    # File lib/jekyll/core_ext.rb, line 8
    def deep_merge(hash)
      target = dup

      hash.keys.each do |key|
        if hash[key].is_a? Hash and self[key].is_a? Hash
          target[key] = target[key].deep_merge(hash[key])
          next
        end

        target[key] = hash[key]
      end

      target
    end

pluralized_array(singular_key, plural_key) click to toggle source

Read array from the supplied hash favouring the singular key and then the plural key, and handling any nil entries.

    +hash+ the hash to read from
    +singular_key+ the singular key
    +plural_key+ the plural key

Returns an array

    # File lib/jekyll/core_ext.rb, line 30
    def pluralized_array(singular_key, plural_key)
      hash = self
      if hash.has_key?(singular_key)
        array = [hash[singular_key]] if hash[singular_key]
      elsif hash.has_key?(plural_key)
        case hash[plural_key]
        when String
          array = hash[plural_key].split
        when Array
          array = hash[plural_key].compact
        end
      end
      array || []
    end

symbolize_keys() click to toggle source

    # File lib/jekyll/core_ext.rb, line 52
    def symbolize_keys
      dup.symbolize_keys!
    end

symbolize_keys!() click to toggle source

    # File lib/jekyll/core_ext.rb, line 45
    def symbolize_keys!
      keys.each do |key|
        self[(key.to_sym rescue key) || key] = delete(key)
      end
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.