Sha256: b07b9b95b4ddd1a538ebe53830dda5ab31a684dcdcfdeaae9472360cd2dd9265

Contents?: true

Size: 569 Bytes

Versions: 3

Compression:

Stored size: 569 Bytes

Contents

module ActiveRecord
  module QueryMethods
    # Store chain for array columns.
    class ArrayChain < StoreChain
      # Whether the array overlaps provided array.
      #
      # Example
      #   Model.create!(name: 'first', store: ['b', 'c'])
      #   Model.create!(name: 'second', store: ['a', 'b'])
      #
      #   Model.store(:store).overlap('c').all #=> [Model(name: 'first', ...)]
      #   Model.store(:store).overlap(['b']).size #=> 2
      def overlap(*vals)
        update_scope "#{@store_name} && #{type_cast(vals.flatten)}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pgrel-0.1.2 lib/pgrel/active_record/store_chain/array_chain.rb
pgrel-0.1.1 lib/pgrel/active_record/store_chain/array_chain.rb
pgrel-0.1.0 lib/pgrel/active_record/store_chain/array_chain.rb