module LearnWeb::AttributePopulatable
Public Class Methods
included(base)
click to toggle source
# File lib/learn_web/attribute_populatable.rb, line 3 def self.included(base) base.class_eval do def populate_attributes! data.each do |attribute, value| if !self.respond_to?(attribute) self.class.class_eval do attr_accessor attribute end end self.send("#{attribute}=", value) end end end end
Public Instance Methods
populate_attributes!()
click to toggle source
# File lib/learn_web/attribute_populatable.rb, line 5 def populate_attributes! data.each do |attribute, value| if !self.respond_to?(attribute) self.class.class_eval do attr_accessor attribute end end self.send("#{attribute}=", value) end end