Skip to content

Instantly share code, notes, and snippets.

@listrophy
Created October 9, 2012 23:20
Show Gist options
  • Save listrophy/3862098 to your computer and use it in GitHub Desktop.
Save listrophy/3862098 to your computer and use it in GitHub Desktop.
Mockingbird example
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