Sha256: 59a921768c40905e32343b55537b7ced8216bc111f070ba7bcfff5ab7d9c5fa2

Contents?: true

Size: 495 Bytes

Versions: 21

Compression:

Stored size: 495 Bytes

Contents

module CassandraObject
  module AttributeMethods
    class Definition
      attr_reader :name, :coder
      def initialize(name, coder, options)
        @name   = name.to_s
        @coder  = coder.new(options)
      end

      def default
        coder.default
      end

      def instantiate(record, value)
        value = value.nil? ? coder.default : value
        return if value.nil?

        value.kind_of?(String) ? coder.decode(value) : coder.typecast(value)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
extendi-cassandra_object-1.0.0 lib/cassandra_object/attribute_methods/definition.rb