lib/ahub/modules/class_helpers.rb in ahub-0.2.0 vs lib/ahub/modules/class_helpers.rb in ahub-0.3.1
- old
+ new
@@ -6,10 +6,16 @@
def destroy
raise NotImplementedError
end
- def self.included(klass)
- attr_reader :id
+ def initialize(attrs)
+ attrs.each_pair do |k,v|
+ self.instance_variable_set("@#{k.to_s.underscore}", v)
+
+ self.class.send(:define_method, k.to_s.underscore.to_sym) do
+ instance_variable_get("@#{__method__}")
+ end
+ end
end
end
end