Sha256: ccd4ce982a281c8ae170904f32508db595ae1775157aca3effc0138a3d78ed9a

Contents?: true

Size: 548 Bytes

Versions: 3

Compression:

Stored size: 548 Bytes

Contents

module Unsplash # :nodoc:

  # Unsplash Search operations
  class Search < Client
    class << self
      # Helper class to facilitate search on multiple classes
      # @param url [String] Url to be searched into
      # @param klass [Class] Class to instantiate the contents with
      # @param params [Hash] Params for the search
      def search(url, klass, params)
        list = JSON.parse(connection.get(url, params).body)

        list["results"].map do |content|
          klass.new content.to_hash
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
unsplash-1.4.2 lib/unsplash/search.rb
unsplash-1.4.1 lib/unsplash/search.rb
unsplash-1.4.0 lib/unsplash/search.rb