Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created May 20, 2011 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leejarvis/a42e32041a84d8959020 to your computer and use it in GitHub Desktop.
Save leejarvis/a42e32041a84d8959020 to your computer and use it in GitHub Desktop.
class Person
include Questionable
questionable :name, :age
questionable :has_password? => :password
questionable :friends_with_robert? => :friends do |friends|
friends.include? 'Robert'
end
questionable :has_friend? => :friends do |friends, friend|
friends.include? friend
end
def initialize(name, age, password=nil)
@name = name
@age = age
@password = password
@friends = ['Phil', 'Robert']
end
end
roy = Person.new 'Roy', 36, 'Sekret!!'
roy.name? #=> true
roy.has_password? #=> true
roy.friends_with_robert? #=> true
dave = Person.new 'Dave', 42
dave.age? #=> true
dave.has_password? #=> false
dave.has_friend? 'Steve' #=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment