Sha256: a8f32ba88b80104e37689c77d66449b857064090b32bd5e47a416ce25f37dacd
Contents?: true
Size: 542 Bytes
Versions: 1
Compression:
Stored size: 542 Bytes
Contents
module RailsScopes module ScopesCombiner def combined_scopes_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.3 | lib/rails_scopes/scopes_combiner.rb |