Sha256: c928f232953674ecb9d82362f9c2f9f14fbf14eb92898e95fcae4d763ba0c840

Contents?: true

Size: 956 Bytes

Versions: 10

Compression:

Stored size: 956 Bytes

Contents

module MightyGrid
  module MgHash
    class << self
    	# A deep merge of two hashes.
      # That is, if both hashes have the same key and the values are hashes, these two hashes should also be merged.
      # Used for merging two sets of params.
      def rec_merge(hash, other)  #:nodoc:
        res = hash.clone
        other.each do |key, other_value|
          value = res[key]
          if value.is_a?(Hash) && other_value.is_a?(Hash)
            res[key] = rec_merge value, other_value
          else
            res[key] = other_value
          end
        end
        res
      end
    end
  end

  module MgHTML
    class << self
      def join_html_classes(html_options, *html_classes)
        html_options[:class] ||= ''
        html_options[:class] = ([html_options[:class]] + html_classes).reject(&:blank?).map do |h_classes|
          h_classes.split(' ')
        end.flatten.uniq.join(' ')
        html_options
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mighty_grid-0.6.0 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.5.0 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.4.0 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.3.3 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.3.2 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.3.1 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.3.0 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.2.2 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.2.1 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.2.0 lib/mighty_grid/mighty_grid_ext.rb