Sha256: 48004cbad047c6065cfbc574375dff6a304b0fd2157374ba44089c0fea3cd44c
Contents?: true
Size: 843 Bytes
Versions: 1
Compression:
Stored size: 843 Bytes
Contents
module Populator class Record attr_accessor :attributes def initialize(model_class, id) @attributes = { :id => id } @columns = model_class.column_names @columns.each do |column| if column == 'created_at' || column == 'updated_at' @attributes[column.to_sym] = Time.now end if column == 'created_on' || column == 'updated_on' @attributes[column.to_sym] = Date.today end self.instance_eval <<-EOS def #{column}=(value) @attributes[:#{column}] = Populator.interpret_value(value) end def #{column} @attributes[:#{column}] end EOS end end def attribute_values @columns.map do |column| @attributes[column.to_sym] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
populator-0.2.1 | lib/populator/record.rb |