Created
September 16, 2015 21:03
-
-
Save dchandekstark/11773d7080cbc92ec561 to your computer and use it in GitHub Desktop.
OpenStructDelegator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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