Sha256: 20c14c2cda5e4f8c89d2f911c71728feb5e843f728d45d0be56489bad38ac663

Contents?: true

Size: 296 Bytes

Versions: 1

Compression:

Stored size: 296 Bytes

Contents

class KwStruct < Struct
  VERSION = '0.2.0'

  def self.new(*members, &block)
    super.tap do |struct_class|
      struct_class.class_eval <<-RUBY
        def initialize(#{members.map{|m| "#{m}: nil"}.join(', ')})
          super(#{members.join(', ')})
        end
      RUBY
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kwstruct-0.2.0 lib/kwstruct.rb