Sha256: 6a5c3cc021a1b48260f303954e67cd1b4ee3955b097b11349c57a73b2fff20d4

Contents?: true

Size: 419 Bytes

Versions: 8

Compression:

Stored size: 419 Bytes

Contents

# frozen_string_literal: false

if Lite::Ruby.configuration.monkey_patches.include?('struct')
  class Struct

    def [](key)
      attributes[key.to_sym]
    end

    def []=(key, val)
      send("#{key}=", val)
    end

    def attributes
      each_pair.with_object({}) { |(key, val), hash| hash[key] = val }
    end

    def replace(args)
      args.each_pair { |key, val| send("#{key}=", val) }
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lite-ruby-1.3.0 lib/lite/ruby/struct.rb
lite-ruby-1.2.0 lib/lite/ruby/struct.rb
lite-ruby-1.1.15 lib/lite/ruby/struct.rb
lite-ruby-1.1.14 lib/lite/ruby/struct.rb
lite-ruby-1.1.13 lib/lite/ruby/struct.rb
lite-ruby-1.1.12 lib/lite/ruby/struct.rb
lite-ruby-1.1.11 lib/lite/ruby/struct.rb
lite-ruby-1.1.10 lib/lite/ruby/struct.rb