Browse files

Add '?' suffix to generated method names of bools

Objects with values that are either true or false have an '?' appended to
their name to fit with standard Ruby convention. For example, Repository
objects now have a .fork? and .private? method. This convention is not
reflected in the value of the @keys instance variable, because we assume
callers will use it to iterate through the instance variables, whose names do
not have a '?' suffix...

Note: This commit theoretically breaks backward compatibility, as the
unadorned method names no longer work.

This closes #2.

Signed-off-by: Felipe Coury <>
  • Loading branch information...
1 parent 1b902d3 commit 0299a1f1d7840c5e65f454b9090fef85d96a04ad @runpaint committed with fcoury Apr 22, 2009
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/octopi/base.rb
@@ -40,11 +40,13 @@ def initialize(api, hash)
next if k =~ /\./
instance_variable_set("@#{k}", v)
- self.class.send :define_method, "#{k}=" do |v|
+ method = (TrueClass === v || FalseClass === v) ? "#{k}?" : k
+ self.class.send :define_method, "#{method}=" do |v|
instance_variable_set("@#{k}", v)
- self.class.send :define_method, k do
+ self.class.send :define_method, method do

0 comments on commit 0299a1f

Please sign in to comment.