Skip to content

Instantly share code, notes, and snippets.

@snusnu
Created November 24, 2013 22:30
Show Gist options
  • Save snusnu/7633316 to your computer and use it in GitHub Desktop.
Save snusnu/7633316 to your computer and use it in GitHub Desktop.
Path.new.foo.bar.baz.to_a # => [:foo, :bar, :baz]
class Path < BasicObject
def initialize(path = [])
@path = path
end
def to_a
@path.dup
end
private
def method_missing(name, *)
::Path.new(to_a << name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment