Sha256: bf854040109ea320271148bdc02d053f085c29a72bd8c6b589e2eae01680d834

Contents?: true

Size: 543 Bytes

Versions: 1

Compression:

Stored size: 543 Bytes

Contents

module RailsScopes
  module ScopesCombiner
    def combined_methods_names(hash)
      2.upto(hash.size).map do |n|
        hash.keys.combination(n).map { |combined| combined.join('_or_') }
      end.flatten
    end

    def combine_scopes_for_attribute(attribute_name, hash)
      2.upto(hash.size).each do |n|
        hash.keys.combination(n).each do |combined|
          define_singleton_method(combined.join('_or_')) do
            where(attribute_name => combined.map { |k| hash[k] })
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_scopes-0.0.2 lib/rails_scopes/scopes_combiner.rb