Created
October 9, 2012 23:20
-
-
Save listrophy/3862098 to your computer and use it in GitHub Desktop.
Mockingbird example
This file contains 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
class Mockingbird < ActiveRecord::Base | |
attr_accessible :color | |
def chirp! | |
"chirp" | |
end | |
def tweet! | |
"tweet" | |
end | |
def vocalize! | |
if chirpy? | |
chirp! | |
elsif tweety? | |
tweet! | |
end | |
end | |
def chirpy? | |
color == "red" | |
end | |
def tweety? | |
color == "blue" | |
end | |
end | |
def make_em_sing | |
Mockingbird.find_each(&:vocalize!) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment