Method: Unread::Reader::Scopes#join_read_marks

Defined in:
lib/unread/reader_scopes.rb

#join_read_marks(readable) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/unread/reader_scopes.rb', line 10

def join_read_marks(readable)
  assert_readable(readable)

  joins "LEFT JOIN #{ReadMark.quoted_table_name}
          ON #{ReadMark.quoted_table_name}.readable_type  = '#{readable.class.readable_parent.name}'
         AND (#{ReadMark.quoted_table_name}.readable_id   = #{quoted(readable.id)} OR #{ReadMark.quoted_table_name}.readable_id IS NULL)
         AND #{ReadMark.quoted_table_name}.reader_id      = #{quoted_table_name}.#{quoted_primary_key}
         AND #{ReadMark.quoted_table_name}.reader_type    = '#{connection.quote_string base_class.name}'
         AND #{ReadMark.quoted_table_name}.timestamp     >= '#{connection.quoted_date readable.send(readable.class.readable_options[:on])}'"
end