Sha256: b744afb3fa90035b05c56059d0485a2bcf0f584cef44b6f19e3d0abcbcb9363b

Contents?: true

Size: 613 Bytes

Versions: 10

Compression:

Stored size: 613 Bytes

Contents

module CassandraObject
  module FindWithIds
    extend ActiveSupport::Concern

    module ClassMethods
      def find_with_ids(ids, options=nil)
        expects_array = ids.first.kind_of?(Array)
        return ids.first if expects_array && ids.first.empty?

        ids = ids.dup
        ids.flatten!
        ids.compact!
        ids.collect!(&:to_s)
        ids.uniq!

        #raise RecordNotFound, "Couldn't find #{record_klass.name} without an ID" if ids.empty?

        results = multi_get(ids).values.compact

        results.size <= 1 && !expects_array ? results.first : results
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gotime-cassandra_object-0.9.1 lib/cassandra_object/find_with_ids.rb
gotime-cassandra_object-0.9.0 lib/cassandra_object/find_with_ids.rb
gotime-cassandra_object-0.8.7 lib/cassandra_object/find_with_ids.rb
gotime-cassandra_object-0.8.6 lib/cassandra_object/find_with_ids.rb
gotime-cassandra_object-0.8.5 lib/cassandra_object/find_with_ids.rb
gotime-cassandra_object-0.8.4 lib/cassandra_object/find_with_ids.rb
gotime-cassandra_object-0.8.3 lib/cassandra_object/find_with_ids.rb
gotime-cassandra_object-0.8.2 lib/cassandra_object/find_with_ids.rb
gotime-cassandra_object-0.8.1 lib/cassandra_object/find_with_ids.rb
gotime-cassandra_object-0.8.0 lib/cassandra_object/find_with_ids.rb