Module: AlmostHappy::Scopeable::ClassMethods

Defined in:
lib/almost_happy/scopeable.rb

Instance Method Summary collapse

Instance Method Details

#orderedObject



15
16
17
# File 'lib/almost_happy/scopeable.rb', line 15

def ordered
  order "#{quoted_table_name}.published_at DESC"
end

#ordered_for_previewObject



19
20
21
# File 'lib/almost_happy/scopeable.rb', line 19

def ordered_for_preview
  order "(#{quoted_table_name}.published_at IS NULL) DESC, #{quoted_table_name}.published_at DESC"
end

#publishedObject



7
8
9
# File 'lib/almost_happy/scopeable.rb', line 7

def published
  where "#{quoted_table_name}.published_at IS NOT NULL AND #{quoted_table_name}.published_at <= ?", Time.now
end

#unpublishedObject



11
12
13
# File 'lib/almost_happy/scopeable.rb', line 11

def unpublished
  where "#{quoted_table_name}.published_at IS NULL OR #{quoted_table_name}.published_at > ?", Time.now
end