Sha256: 39b7bac0aece9d823f5df1bcd7345eb2011358db5f3aa4cc0a4260ee3b194e14
Contents?: true
Size: 1011 Bytes
Versions: 2
Compression:
Stored size: 1011 Bytes
Contents
# frozen_string_literal: true class Zilla::Versions::V20::Client include Zilla::Versions::V20 include Memery attr_reader :json, :host, :scheme, :faraday_config_block def initialize(json, host: nil, scheme: nil, faraday_config_block: nil) # rubocop:disable Metrics/AbcSize @json = json @host = host || api.host || raise(ArgumentError, ":host must be specified") @scheme = (scheme || :https).to_s @faraday_config_block = faraday_config_block || ->(_f, _target) {} if api.schemes && !api.schemes.include?(@scheme) raise ArgumentError, "unsupported scheme #{@scheme.inspect}. Supported: #{api.schemes}" end define_operations! end memoize def api = API.new(json) memoize def executor = Executor.new(scheme, host, faraday_config_block:) private def define_operations! api.endpoints.each do |endpoint| define_singleton_method(endpoint.operationId) do |*args, **params| executor.call(endpoint, *args, **params) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zilla-0.1.3 | lib/zilla/versions/v20/client.rb |
zilla-0.1.2 | lib/zilla/versions/v20/client.rb |