I am getting the following error:
ShowsQueryObject querying for a show by start date returns shows that are after the start date
Failure/Error: expect(ShowsQueryObject.query(start_date: start_date)).to match_array [after_start_date_show_1, after_start_date_show_2]
NoMethodError:
undefined method `query_params' for ShowsQueryObject:Class
For this code:
class ShowsQueryObject
class << self
def query(query_params)
Show.where(query_string(query_params), query_values(query_params))
end
private
def query_string(query_params)
query_string = []
query_string << start_date_query if query_params(:start_date)
query_string << end_date_query if query_params(:end_date)
query_string << artist_name_query if query_params(:artist_name)
query_string << venue_id_query if query_params(:venue_id)
query_string.join(' AND ')
end
def query_values(query_params)
{}.tap do |hash|
hash[:start_date] = query_params(:start_date) if query_params(:start_date)
hash[:end_date] = query_params(:end_date) if query_params(:end_date)
hash[:artist_name] = query_params(:artist_name) if query_params(:artist_name)
hash[:venue_id] = query_params(:venue_id) if query_params(:venue_id)
end
end
...
end
end
I am guessing this has something to do with private static methods in Ruby? This is my first time messing around with class << self so I'm assuming I did something wrong, but from what I can find on line this all looks legit to me.