Sha256: 06e84661e8c7c87dab489b61fbb8cc27f5c3968d6bc5e951cbc733be435cfebb
Contents?: true
Size: 749 Bytes
Versions: 1
Compression:
Stored size: 749 Bytes
Contents
module Zvents class SearchResults require 'zvents/event' require 'zvents/venue' include Virtus.model attribute :events, Array[Event] attribute :venues, Array[Venue] def events unless @venues_initialized venue_hash = {} # A hash allows for this method to be run in linear time # at the cost of space @venues.each do |venue| venue_hash[venue.id] = venue end @events.each do |event| event.venue = venue_hash[event.venue_id] end end @venues_initialized = true @events end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zvents-0.1.1 | lib/zvents/search_results.rb |