module OmniStruct

Top level class, mainly for correct requiring, but wraps Hash extensions as well.

Public Class Methods

new(hash=Hash.new, type=Hash.struct_type) click to toggle source

Wraps Hash.to_struct

Examples:

s = OmniStruct.new({:foo => :bar})
s.class
#=> ClassyHashStruct
s.foo
#=> :bar

s = OmniStruct.new({:foo => :bar})
s.class
#=> ClassyHashStruct
s.foo
#=> :bar
# File omnistruct.rb, line 24
def self.new hash=Hash.new, type=Hash.struct_type
  return hash.to_struct(type)
end
struct_type() click to toggle source

Wraps Hash.struct_type

# File omnistruct.rb, line 29
def self.struct_type
  Hash.struct_type
end
struct_type=(type) click to toggle source

Wraps Hash.struct_type=

# File omnistruct.rb, line 34
def self.struct_type= type
  Hash.struct_type = type
end

Protected Class Methods

struct_types() click to toggle source

Wraps Hash.struct_types

# File omnistruct.rb, line 40
def self.struct_types
  Hash.send(:struct_types)
end