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.1.1 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.1.0 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.20 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.19 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.18 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.17 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.16 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.15 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.14 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.13 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.12 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.11 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.10 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.9 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.8 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.7 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.6 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.5 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.4 lib/cassandra_object/attribute_methods/definition.rb
extendi-cassandra_object-1.0.1 lib/cassandra_object/attribute_methods/definition.rb