Sha256: 78eface386c66416a14db419b74bb7985fb140488206288b7636e614a46454d0
Contents?: true
Size: 691 Bytes
Versions: 3
Compression:
Stored size: 691 Bytes
Contents
module Effective class ModelReader DATATYPES = [:binary, :boolean, :date, :datetime, :decimal, :float, :hstore, :inet, :integer, :string, :text] attr_reader :attributes def initialize(&block) @attributes = {} instance_exec(&block) end def method_missing(m, *args, &block) raise "#{m} has already been defined" if attributes[m] if m == :timestamps attributes[:created_at] = [:datetime] attributes[:updated_at] = [:datetime] return end unless DATATYPES.include?(args.first) raise "expected first argument to be a datatype. Try name :string" end attributes[m] = args end end end
Version data entries
3 entries across 3 versions & 1 rubygems