module Quandl::Cassandra::Base::Sanitization::ClassMethods

Public Instance Methods

bind_primary_key(*args) click to toggle source
# File lib/quandl/cassandra/base/sanitization.rb, line 5
def bind_primary_key(*args)
  attrs = {}
  primary_key.each_with_index { |k, i| attrs[k] = args[i] if args[i].present? }
  attrs
end
sanitize_attribute(attribute, value) click to toggle source
# File lib/quandl/cassandra/base/sanitization.rb, line 22
def sanitize_attribute(attribute, value)
  # process each value
  return value.map { |val| column_type(attribute).sanitize_for_cql(val) } if value.is_a?(Array)
  # process value
  column_type(attribute).sanitize_for_cql(value)
end
sanitize_attributes(attrs) click to toggle source
# File lib/quandl/cassandra/base/sanitization.rb, line 11
def sanitize_attributes(attrs)
  values = {}
  attrs.each do |attribute, value|
    # exclude attributes that are not present in columns
    next unless column_type(attribute)
    # sanitize value for cql
    values[attribute] = sanitize_attribute(attribute, value)
  end
  values
end