class HandyHash::Builder

@api private

Public Class Methods

new(&block) click to toggle source
# File lib/handy_hash.rb, line 102
def initialize(&block)
  @content = {}
  instance_eval &block if block_given?
end

Public Instance Methods

data() click to toggle source
# File lib/handy_hash.rb, line 123
def data
  HandyHash.new.tap do |d|
    @content.each do |k, v|
      d[k] = v.kind_of?(Builder) ? v.data : v
    end
  end
end
method_missing(m, *args, &block) click to toggle source
Calls superclass method
# File lib/handy_hash.rb, line 107
def method_missing(m, *args, &block)
  if m =~ /\Ato_ary\Z/ || m =~ /\=$/ || args.size > 1
    super
  else
    m = m.to_s
    if m =~ /\A_(.+)_\Z/
      m = $1 
    end
    if args.empty?
      @content[m] = Builder.new(&block)
    else
      @content[m] = args.first
    end
  end
end