Sha256: 8a295a1ec9fda98e85fc60e03afab2eff1e70393ccef09bcd7c483295fd414c3

Contents?: true

Size: 591 Bytes

Versions: 2

Compression:

Stored size: 591 Bytes

Contents

class Cassandra::Mapper::Data
  class Insert < Request
    def initialize(_config, data)
      @request = data.dup
      super
    end

    def convert!(data)
      config.before_insert.each {|it| it.call data }
      super
    end

    def return!
      converted.tap do |data|
        config.after_insert.each {|it| it.call data }
      end
    end

    private

    def converted
      @request.each_with_object({}) do |(field, value), converted|
        next unless value
        converted[field] = Cassandra::Mapper::Convert.round config.types[field], value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cassandra-mapper-0.2 lib/cassandra/mapper/data/insert.rb
cassandra-mapper-0.1 lib/cassandra/mapper/data/insert.rb