Sha256: 606eaec55956541c8605cd84b26a887b213a523e372851d53e7955a8ac98929b

Contents?: true

Size: 593 Bytes

Versions: 1

Compression:

Stored size: 593 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 "response_body = #{ret[:response_body]}" if ret.is_a?(Hash) && ret[:status] == false
            ret
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flow-cli-0.0.3 lib/flow/cli/utils/flow_api_rest.rb