Clever OpenStruct
Just as OpenStruct, but more clever (maybe not so efficient, it's just code, rewrite it)
GNU nano 2.2.4 File: open_struct_extension.rb
module Clever ; end
class Clever::OpenStruct
attr :original_data, :struct
def initialize(arg)
@original_data = arg
@struct = OpenStruct.new(arg)
end
def [](key)
@original_data[key]
end
def method_missing(*args)
@struct.send(*args)
end
end
Faster OpenStruct
Ruby Developers might now OpenStruct.
Instead of finding it on Github, I Found Faster::OpenStruct, which aims to be up to 40 times faster.
Let's test