Created
January 28, 2018 13:12
-
-
Save PavloConan/7602ebec67830a5e44126430797c8b11 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
class MyClass | |
def initialize(**args) | |
args.each do |k, v| | |
instance_variable_set("@#{k}", v) | |
define_singleton_method(k) do | |
instance_variable_get(:"@#{k}") | |
end | |
define_singleton_method("#{k}=") do |v| | |
instance_variable_set("@#{k}", v) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment