OpensStructable is a mixin module which can provide OpenStruct behavior to any class or object. OpenStructable allows extention of data objects with arbitrary attributes.

Usage

  require 'mega/ostructable'

  class Record
    include OpenStructable
  end

  record = Record.new
  record.name    = "John Smith"
  record.age     = 70
  record.pension = 300

  puts record.name     # -> "John Smith"
  puts record.address  # -> nil

Author(s)

  • Thomas Sawyer
  • Yukihiro Matsumoto
  • Gavin Sinclair (Documentation)
Methods
Constants
VERSION = '0.9.0'
Public Instance methods
==(other) [ source ]

Compare this object and other for equality.

delete_field(name) [ source ]

Remove the named field from the object.

initialize_copy(orig) [ source ]

Duplicate an OpenStruct object members.

inspect() [ source ]

Returns a string containing a detailed summary of the keys and values.

new_ostruct_member(name) [ source ]
update(hash) [ source ]

Generate additional attributes and values.