rzane/baby_squeel

View on GitHub
lib/baby_squeel/active_record/where_chain.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'baby_squeel/dsl'

module BabySqueel
  module ActiveRecord
    module WhereChain
      # Constructs Arel for ActiveRecord::Base#where using the DSL.
      def has(&block)
        arel = DSL.evaluate(@scope, &block)
        @scope.where!(arel) unless arel.blank?
        @scope
      end
    end
  end
end