lib/liszt.rb
# Return a relation/scope containing objects eligible to be in the list
# that includes the given object.
Return a relation/scope containing objects eligible to be in the list
that includes the given object.
Return a relation / scope containing objects eligible to be in the list that includes the given object .
def liszt_relation(obj={})
      if @liszt_query.nil?
        query = ['1 = 1']
        @liszt_conditions.each do |key, value|
          query.first << " AND (#{table_name}.#{key} "
          if value.nil?
            query.first << "IS NULL)"
          else
            query.first << "= ?)"
            query << value
          end
        end
        @liszt_scope.each do |scope|
          query.first << " AND (#{table_name}.#{scope} = ?)"
        end
        @liszt_query = query
      end
      where(@liszt_query + @liszt_scope.map { |scope| obj[scope] })
    end
def liszt_relation ( obj = { } ) if @liszt_query . nil? query = [ '1 = 1' ] @liszt_conditions . each do | key , value | query . first << " AND (#{table_name}.#{key} " if value . nil? query . first << "IS NULL)" else query . first << "= ?)" query << value end end @liszt_scope . each do | scope | query . first << " AND (#{table_name}.#{scope} = ?)" end @liszt_query = query end where ( @liszt_query + @liszt_scope . map { | scope | obj [ scope ] } ) end
Return a relation/scope containing objects eligible to be in the list
that includes the given object.
Return a relation / scope containing objects eligible to be in the list that includes the given object .
obj
<not_specific>