Source

RubyCSharp / RSpec_samples / user.rb

Full commit
class String
   def ends_with?(suffix)
     suffix = suffix.to_s
     self[-suffix.length..-1] == suffix
   end
 end

class User

  def initialize(profile)
    @profile = profile
  end

#  def doctor?
#    @profile == 'doctor'
#  end
  
#  def patient?
#    @profile == 'patient'
#  end

  def method_missing(method_name, *args, &block)
    
    method_name = method_name.to_s
    if method_name.ends_with?("?")
      return @profile == method_name.chop
    end
    
    super if self.response_to?(method_name)
  end
end