Created
May 12, 2010 20:37
-
-
Save timruffles/399092 to your computer and use it in GitHub Desktop.
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
require 'net/http' | |
require 'yaml' | |
module Configable | |
def configure(setup) | |
setup.each_pair do |key,val| | |
if self.respond_to? key + '=' | |
self.send(key + '=', val) | |
else | |
instance_variable_set('@' + key, val) | |
end | |
end | |
end | |
end | |
class Github | |
include Configable | |
def initialize(setup) | |
configure(setup) | |
end | |
attr_accessor :user, :pass | |
end | |
g = Github.new({'user'=>'bar','pass'=>'bim'}) | |
puts g.user # = bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment