Module: Hashie::Extensions::MergeInitializer

Defined in:
lib/3rdparty/hashie/merge_initializer.rb

Overview

The MergeInitializer is a super-simple mixin that allows you to initialize a subclass of Hash with another Hash to give you faster startup time for Hash subclasses. Note that you can still provide a default value as a second argument to the initializer.

Examples:

class MyHash < Hash
  include Hashie::Extensions::MergeInitializer
end

h = MyHash.new(:abc => 'def')
h[:abc] # => 'def'

Instance Method Summary collapse

Instance Method Details

#initialize(hash = {}, default = nil, &block) ⇒ Object



19
20
21
22
# File 'lib/3rdparty/hashie/merge_initializer.rb', line 19

def initialize(hash = {}, default = nil, &block)
  default ? super(default) : super(&block)
  update(hash)
end