Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
For use with https://github.com/chancancode/json_expressions. Allows you to write either(FooClass, BarClass). Useful if you're expecting nils.
module JsonExpressionHelper
def either *klasses
Class.new(Object) do
@klasses = klasses
def self.===(other)
@klasses.reduce(false) { |memo, klass| memo ||= (other.class == klass) }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.