Sha256: a27a598ccf6cbf5b2618158bc86b991476ff8a8bc1d8a07aabca8073c31fdb01
Contents?: true
Size: 995 Bytes
Versions: 1
Compression:
Stored size: 995 Bytes
Contents
# frozen_string_literal: true require 'attr_extras' require 'active_support/core_ext/module' require 'json' module RavencoinRpc class Client # This is class to validate selected method and generate requst params class Request pattr_initialize %i[method! args] do @args ||= [] end delegate :call, to: :data private def data -> { valid? ? prepare_data : error } end def valid? methods.include?(method) end def methods @methods ||= docs.keys end def docs @docs ||= JSON.parse(File.open(Gem::Specification.find_by_name("ravencoin_rpc_ruby").gem_dir + '/docs.json').read) end def error raise RavencoinRpc::Exceptions::NotFoundModule, 'method not included into methods list' end def prepare_data { jsonrpc: '2.0', id: rand(10), method: method, params: args } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ravencoin_rpc_ruby-0.3.1 | lib/ravencoin_rpc/client/request.rb |