Skip to content

Instantly share code, notes, and snippets.

@johnathancroom
Created July 12, 2012 20:24
Show Gist options
  • Save johnathancroom/3100723 to your computer and use it in GitHub Desktop.
Save johnathancroom/3100723 to your computer and use it in GitHub Desktop.
Chained Methods
module Vermonster
module Lists
def lists
self.class::Lists
end
class Lists
def self.all
Vermonster::Client.connection # Use this anywhere you want the connection
end
end
end
module Tasks
def tasks
self.class::Tasks
end
class Tasks
def self.all
"hi"
end
end
end
end
module Vermonster
class Client
def connect!
@@connection = [{"id" => 1, "crap" => "teag"}, {"id" => 2, "crap" => "yeah"}, {"id" => 3, "crap" => "yeah"}]
self
end
def self.connection
@@connection
end
include Lists
include Tasks
end
end
cheddar = Vermonster::Client.new
cheddar.connect!
puts cheddar.lists.all
puts cheddar.tasks.all
@ethnt
Copy link

ethnt commented Jul 12, 2012

FUCK YEAH

@johnathancroom
Copy link
Author

YESSSSS

@ethnt
Copy link

ethnt commented Jul 12, 2012

YUP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment