Sha256: 8459d15aaedcfbe0298e72cfbbbdd46dbe8b3db09b78d128af8c44005ce6e232
Contents?: true
Size: 747 Bytes
Versions: 1
Compression:
Stored size: 747 Bytes
Contents
# frozen_string_literal: true module Omdb module Api module PublicApi %i[find_by_id find_by_title search].each do |method| define_method(method) do |value, **options| request = Omdb::Api::Request.new(api_key, method, value, options) if method == :search && request.success? movies = [].tap do |m| request.response.fetch('Search').each do |movie| m << Omdb::Api::Movie.new(movie) end end Omdb::Api::Collection.new(movies) elsif request.success? Omdb::Api::Movie.new(request.response) else Omdb::Api::Error.new(request.response) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omdb-api-1.0.0 | lib/omdb/api/public_api.rb |