Sha256: 51b2a506aaaf001889eaf558e42a55f289d854e784b70c13d21d5fa75ecc4016

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

module OMCMS
  class Resource
    def initialize(client, _response = {}, host = nil)
      @client = client
      @host = host
    end

    private

    def response_class(name)
      Kernel.const_get("OMCMS::Response::#{name}")
    end

    def perform_run(instance, path)
      request_url = [@host, "api", "apps", path].compact.join("/")
      class_name = instance.class.name.split("::").last
      response = @client.get request_url

      return response if response.instance_of?(OMCMS::Response::Error)

      response_class(class_name).new(@client, response, @host)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omcms-ruby-client-1.2.0 lib/omcms/resource.rb