Sha256: 93bcfb4816cd0a65ad1b5eee85d64ddff21ce07281a1e8737d361a9b32a7d524

Contents?: true

Size: 663 Bytes

Versions: 2

Compression:

Stored size: 663 Bytes

Contents

require "ya/api/direct/constants"

module Ya::API::Direct
  class DirectServiceBase
    attr_reader :method_items, :version
    def initialize(client, methods)
      @client = client
      @method_items = methods
      init_methods
    end

    protected

    def exec_request(method, request_body)
      client.gateway.request method, request_body, @version
    end

    def init_methods
      @method_items.each do |method|
        self.class.send :define_method, method do |params = {}|
          result = exec_request(method, params || {})
          @client.update_units_data result[:units_data]
          result[:data]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ya-api-direct-0.2.1 lib/ya/api/direct/direct_service_base.rb
ya-api-direct-0.2.0 lib/ya/api/direct/direct_service_base.rb