Created
April 5, 2016 06:22
-
-
Save drobune/d65f3addf906c2102a2b1806b616bb00 to your computer and use it in GitHub Desktop.
hashを受け取ってアクセス可能なインスタンス変数を生成するクラス
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
class Gabagaba | |
def initialize(opts = {}) | |
opts.each do |key, value| | |
self.class.class_eval { attr_accessor "#{key}" } | |
self.instance_variable_set "@#{key}" value | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment