Class: DonationSearch

Inherits:
Object
  • Object
show all
Defined in:
app/models/donation_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start, stop, organization) ⇒ DonationSearch

Returns a new instance of DonationSearch.



5
6
7
8
9
10
# File 'app/models/donation_search.rb', line 5

def initialize(start, stop, organization)
  @organization = organization
  @start = start_with(start)
  @stop  = stop_with(stop)
  @results = yield(results) if block_given?
end

Instance Attribute Details

#startObject (readonly)

Returns the value of attribute start.



3
4
5
# File 'app/models/donation_search.rb', line 3

def start
  @start
end

#stopObject (readonly)

Returns the value of attribute stop.



3
4
5
# File 'app/models/donation_search.rb', line 3

def stop
  @stop
end

Instance Method Details

#resultsObject



12
13
14
# File 'app/models/donation_search.rb', line 12

def results
  @results ||= Order.in_range(@start, @stop, @organization.id).select(&:has_donation?).sort_by(&:created_at)
end