Module: Attrio::Initialize
- Defined in:
- lib/attrio/initialize.rb
Instance Method Summary collapse
Instance Method Details
#new(*args, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/attrio/initialize.rb', line 5 def new(*args, &block) obj = self.allocate obj.send :initialize, *args, &block obj.class.attrio.each do |group, | obj.instance_variable_set("@#{group}", {}) obj.class.send("#{group}").each do |name, attribute| obj.send("#{group}")[name] = attribute.dup obj.send("#{group}")[name].instance_variable_set(:@object, obj) obj.send("#{group}")[name].reset! if obj.send(name).blank? end end obj end |