af83/chouette-core

View on GitHub
app/lib/query/company.rb

Summary

Maintainability
A
35 mins
Test Coverage
module Query
  class Company < Base
    def text(value)
      change_scope(if: value.present?) do |scope|
        table = scope.arel_table

        name = table[:name].matches("%#{value}%")
        objectid = table[:objectid].matches("%#{value}%")

        scope.where(name.or(objectid))
      end
    end

    def without_country
      scope.where(country_code: nil)
    end
  end
end