Created
July 12, 2012 20:24
-
-
Save johnathancroom/3100723 to your computer and use it in GitHub Desktop.
Chained Methods
This file contains hidden or 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
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
commented
Jul 12, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment