0.0
No commit activity in last 3 years
No release in over 3 years
Reimplementation of OpenStruct that uses binding object as data store
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.13
~> 10.0
 Project Readme

BBOpenstruct

This gem contains BBOpenStruct (Binding-based openstruct) class - reimplementation of OpenStruct that uses binding to store your data internally. Why? For science. You monster.

Test file is actually taken from original openstruct implementation, so API is nearly identical.

Installation

Add this line to your application's Gemfile:

gem 'bb_openstruct'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bb_openstruct

Usage

Use it like your normal OpenStruct:

require 'bb_openstruct'
bb = BBOpenStruct.new(a: 1)
bb.a # => 1
bb[:a] # => 1
bb.new_var = 20
bb.new_var # => 20

Should I use it on production

Well... I don't really know what can go wrong, however I'm not sure it's very good idea.

Benchmarks

creation
Openstruct:   719494.0 i/s
BBOpenstruct:    54072.0 i/s - 13.31x  slower

get
Openstruct:  3548217.5 i/s
BBOpenstruct:  3170859.8 i/s - same-ish: difference falls within error

set
BBOpenstruct:  2470835.7 i/s
Openstruct:  1730367.3 i/s - 1.43x  slower

set different
Openstruct:  1163716.8 i/s
BBOpenstruct:  1145259.5 i/s - same-ish: difference falls within error

(benchmarks code can be found in benchmark.rb file)

License

The gem is available as open source under the terms of the MIT License.