Sha256: 53fb67c74276e370402f0b3124c8bbeefc8cc65fd88decea5e787739394e8496

Contents?: true

Size: 803 Bytes

Versions: 3

Compression:

Stored size: 803 Bytes

Contents

module GroupedScope
  module Arish
    module PredicateBuilder
      
      extend ActiveSupport::Concern
      
      included do
        singleton_class.alias_method_chain :build_from_hash, :grouped_scope
      end
      
      module ClassMethods
        
        def build_from_hash_with_grouped_scope(engine, attributes, default_table)
          attributes.select{ |column, value| GroupedScope::SelfGroupping === value }.each do |column_value|
            column, value = column_value
            attributes[column] = value.arel_table[column.to_s].in(value.ids_sql)
          end
          build_from_hash_without_grouped_scope(engine, attributes, default_table)
        end
        
      end

    end
  end
end

ActiveRecord::PredicateBuilder.send :include, GroupedScope::Arish::PredicateBuilder

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grouped_scope-3.1.2 lib/grouped_scope/arish/relation/predicate_builer.rb
grouped_scope-3.1.1 lib/grouped_scope/arish/relation/predicate_builer.rb
grouped_scope-3.1.0 lib/grouped_scope/arish/relation/predicate_builer.rb