Skip to content

Instantly share code, notes, and snippets.

@dchandekstark
Created September 16, 2015 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dchandekstark/11773d7080cbc92ec561 to your computer and use it in GitHub Desktop.
Save dchandekstark/11773d7080cbc92ec561 to your computer and use it in GitHub Desktop.
OpenStructDelegator
require "ostruct"
require "delegate"
class OpenStructDelegator < SimpleDelegator
def initialize(args)
super OpenStruct.new(args)
end
def to_json
require "json"
to_h.to_json
end
def ==(other)
other.is_a?(self.class) && other.__getobj__ == __getobj__
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment