Class: Hystorical::ARRelation

Inherits:
Object
  • Object
show all
Defined in:
lib/hystorical/ar_relation.rb

Class Method Summary collapse

Class Method Details

.current(collection) ⇒ Object



4
5
6
7
# File 'lib/hystorical/ar_relation.rb', line 4

def current(collection)
  current_items = collection.where(end_date: nil)
  block_given? ? current_items.select { |item| yield item } : current_items
end

.current_on(collection, date) ⇒ Object



9
10
11
12
# File 'lib/hystorical/ar_relation.rb', line 9

def current_on(collection, date)
  current_items = collection.where("? BETWEEN start_date AND end_date", date)
  block_given? ? current_items.select { |item| yield item } : current_items
end