Pure Struct

Pure Ruby re-implementation of Struct to ensure cross-Ruby functionality where needed (e.g. Opal)

It is useful when: - There is a need for a Struct class that works consistently across esoteric implementations of Ruby like Opal. This is useful when writing cross-Ruby apps like those of Glimmer relying on YASL (Yet Another Serialization Library) in Opal. - There is a need to meta-program Struct's data - There are no big performance requirements that demand native Struct

In all other cases, stick to native Ruby Struct instead since it's optimized for performance.

Usage Instructions

Run:

gem install pure-struct

Or add to Gemfile:

gem 'pure-struct', '~> 1.0.2'

If you want to use in Opal only inside Rails, suffix with require: false:

gem 'pure-struct', '~> 1.0.2', require: false

And, run:

bundle

Finally, require in Ruby code:

require 'pure-struct'

Note that it removes the native Struct implementation first, aliasing as NativeStruct should you still need it, and then redefining Struct in pure Ruby.

Optionally, you may code block the require statement by a specific Ruby engine like Opal:

if RUBY_ENGINE == 'opal'
  require 'pure-struct'
end

Contributing to pure-struct

Software Process

Glimmer Process

TODO

TODO.md

Change Log

CHANGELOG.md

MIT

Copyright © 2021 Andy Maleh.