# = instance_delegate.rb
#
# == Acknowledgements
#
# * Robert J. Berger <rberger AT ibd.com>
# Thanks for reporting issues that this method resolved.

require 'ostruct'

class OpenStruct

  # Provides access to an OpenStruct's inner table.
  #
  #   o = OpenStruct.new
  #   o.a = 1
  #   o.b = 2
  #   o.instance_delegate.each { |k, v| puts "#{k} #{v}" }
  #
  # produces
  #
  #   a 1
  #   b 2
  #

  def instance_delegate
    @table
  end

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TestOpenStruct < Test::Unit::TestCase

    def setup
      @o = OpenStruct.new(:q => 1)
    end

    def test_store
      @o.instance_delegate.store(:a,1)
      assert_equal( 1, @o.a )
    end

    def test_update
      @o.instance_delegate.update(:a=>1)
      assert_equal( 1, @o.a )
    end

  end

=end
