Sha256: aa9fece0f6fb93f4340f173d5fa8ce6baf416329ff2347c1623eb5d85dffe0b2

Contents?: true

Size: 607 Bytes

Versions: 4

Compression:

Stored size: 607 Bytes

Contents

require_relative './local_service_rest'
module Flow::Cli
  module Utils
    class FlowApiRest < LocalServiceRest
      class << self
        def basic_url
          FLOW_API_URL # 子类中复写
        end

        %i[get delete head post patch put].each do |method|
          alias_method "#{method}_old", method
          define_method method do |*args, &blk|
            ret = __send__ "#{method}_old", *args, &blk
            raise FlowApiError, "response_body = #{ret[:response_body]}" if ret.is_a?(Hash) && ret[:status] == false
            ret
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flow-cli-0.0.7 lib/flow/cli/utils/flow_api_rest.rb
flow-cli-0.0.6 lib/flow/cli/utils/flow_api_rest.rb
flow-cli-0.0.5 lib/flow/cli/utils/flow_api_rest.rb
flow-cli-0.0.4 lib/flow/cli/utils/flow_api_rest.rb