Sha256: f5795820acafbaf03fc22f0c83e2adbd6ab200b2942a17933ffced24c60cb58f

Contents?: true

Size: 361 Bytes

Versions: 1

Compression:

Stored size: 361 Bytes

Contents

# A drop-in replacement for Struct which adds a more flexible initialize method
class FlexStruct
  autoload :VERSION, "flex_struct/version"

  def self.new(*args)
    Struct.new(*args) do
      def initialize(*args, **kwargs)
        super(*args)
        kwargs.each { |key, val| self[key] = val }
        yield self if block_given?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flex_struct-0.1.0 lib/flex_struct.rb