Sha256: 496b446c051dc5ec4c5b34a013f1db0c343d95a6e5730c87b89576d95d73c9dc

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

module Hungry
  class Venue
    class Collection < Hungry::Collection
      include Pagination
      
      def search(query)
        all query: query
      end
      
      def nearby(location, options = {})
        options[:geolocation]   = Geolocation.parse(location)
        options[:sort_by]     ||= 'distance'
        
        all options
      end
      
      def tagged_with(*tags)
        all tags: (current_tags + tags.flatten).compact.join(',')
      end
      
      def sort_by(subject)
        all sort_by: subject
      end
      
      private
      
      def current_tags
        if criteria[:tags].is_a?(String)
          criteria[:tags].gsub(/\s+/, '')
                         .split(',')
        else
          criteria[:tags] || []
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hungry-0.0.1 lib/hungry/venue/collection.rb