Sha256: 48b2ebb2a372cc187ed8e17ae4bb1d18f8dc4967f40c471f4ca802c80f9b039e

Contents?: true

Size: 585 Bytes

Versions: 5

Compression:

Stored size: 585 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.class == OMCMS::Response::Error
      response_class(class_name).new(@client, response, @host)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
omcms-ruby-client-1.1.0 lib/omcms/resource.rb
omcms-ruby-client-1.0.3 lib/omcms/resource.rb
omcms-ruby-client-1.0.2 lib/omcms/resource.rb
omcms-ruby-client-1.0.1 lib/omcms/resource.rb
omcms-ruby-client-1.0.0.pre.alpha lib/omcms/resource.rb