Sha256: becc6524c78d4ac7dcebb7f48c296e15d22462a41e71397933fef8dea9114540

Contents?: true

Size: 527 Bytes

Versions: 10

Compression:

Stored size: 527 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 = value.kind_of?(String) ? coder.decode(value) : value
        coder.wrap(record, name, value)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gotime-cassandra_object-4.12.2 lib/cassandra_object/attribute_methods/definition.rb
gotime-cassandra_object-4.12.1 lib/cassandra_object/attribute_methods/definition.rb
gotime-cassandra_object-4.12.0 lib/cassandra_object/attribute_methods/definition.rb
gotime-cassandra_object-4.11.6 lib/cassandra_object/attribute_methods/definition.rb
gotime-cassandra_object-4.11.5 lib/cassandra_object/attribute_methods/definition.rb
gotime-cassandra_object-4.11.4 lib/cassandra_object/attribute_methods/definition.rb
gotime-cassandra_object-4.11.3 lib/cassandra_object/attribute_methods/definition.rb
gotime-cassandra_object-4.11.2 lib/cassandra_object/attribute_methods/definition.rb
gotime-cassandra_object-4.11.1 lib/cassandra_object/attribute_methods/definition.rb
gotime-cassandra_object-4.11.0 lib/cassandra_object/attribute_methods/definition.rb