Skip to content

Instantly share code, notes, and snippets.

@timruffles
Created May 12, 2010 20:37
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 timruffles/399092 to your computer and use it in GitHub Desktop.
Save timruffles/399092 to your computer and use it in GitHub Desktop.
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