Created
June 18, 2013 12:21
-
-
Save Electron-libre/5804923 to your computer and use it in GitHub Desktop.
Ruby's dynamic accessors demo. Enjoy Ruby power :)
This file contains hidden or 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
module Openerp | |
def self.define_setter(attr) | |
class_eval("def self.#{attr}=(val) \n @@#{attr} = val \n end \n", __FILE__, __LINE__+1) | |
end | |
def self.define_getter(attr) | |
class_eval("def self.#{attr} \n @@#{attr} \n end \n", __FILE__, __LINE__+1) | |
end | |
[:host, :port, :common, :object, :base].each do |attr| | |
define_setter(attr) | |
define_getter(attr) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment