class CamelAndSankeStruct

A small hack written by David Roy to make OpenStruct not care about calling a object via snake_case when it is camelCase

Public Instance Methods

method_missing(method, *args, &blk) click to toggle source
Calls superclass method
# File lib/easy_struct.rb, line 8
def method_missing(method, *args, &blk)
  (/(?<name>.+?)(?<setter>=)?$/ =~ method.to_s)
  property = name.camelcase(:lower).to_sym
  if @table.has_key?(property)
    setter ? @table[property] = args.first : @table[property]
  else
    super
  end
end