Skip to content

Instantly share code, notes, and snippets.

@mieko
Created April 29, 2014 20:13
Show Gist options
  • Save mieko/2a238e98fb005b7de60c to your computer and use it in GitHub Desktop.
Save mieko/2a238e98fb005b7de60c to your computer and use it in GitHub Desktop.
module Opal
module Nodes
module SexpNode
def self.from_sexp(*) # Imagine the extend(ClassMethods) dance.
end
end
end
end
class Opal::Nodes::BaseNode
include SexpNode
end
# Goal:
node = s(:args, ...)
node.class # => Opal::Compiler::ArgsNode
node.is_a?(Sexp) # => true
node.kwrest? # Can have ArgsNode-specific methods
node.children # But still is a Sexp
node.to_s # (:args ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment