Sha256: d21bc85a351a7f7fe3efa3ed70b63a36373816abf076c3ff675854b145f6303e
Contents?: true
Size: 630 Bytes
Versions: 3
Compression:
Stored size: 630 Bytes
Contents
module DeadSimpleDb class Attribute attr_reader :name def initialize(name, klass, opts={}) @name, @opts = name, opts self.klass = klass end def set(value) to_instantiate = @klass value = value.first if value.is_a?(Array) && !to_instantiate.respond_to?(:multiple) to_instantiate = SdbNull if SdbNull::NULL_VALUES.member?(value) @value = to_instantiate.new(value, @opts) end def to_s @value.to_s end def value @value.casted end private def klass=(klass) @klass = instance_eval('Sdb' + klass.to_s) end end end
Version data entries
3 entries across 3 versions & 1 rubygems