Sha256: d5dd64cfea32339c782b5e6bb1dea8f65fb94ebf98c889489a7817d88def80fe

Contents?: true

Size: 750 Bytes

Versions: 11

Compression:

Stored size: 750 Bytes

Contents

module Loquor
  class HttpAction::Get < HttpAction
    def self.get(url, deps)
      new(url, deps).get
    end

    def initialize(url, deps)
      super
    end

    def get
      @config.logger.info "GET: #{full_url}"
      response = @should_cache ? JSON.parse(execute_against_cache) : JSON.parse(execute)
      @config.logger.info "Response: #{response}"
      response
    end

    def execute_against_cache
      cache = @config.cache
      if cache
        val = cache.get(request.url)
        unless val
          val = execute
          cache.set(request.url, val)
        end
        val
      else
        execute
      end
    end

    private
    def request
      RestClient::Request.new(url: full_url, method: :get)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
loquor-1.13.0 lib/loquor/http_actions/get.rb
loquor-1.12.0 lib/loquor/http_actions/get.rb
loquor-1.11.0 lib/loquor/http_actions/get.rb
loquor-1.10.0 lib/loquor/http_actions/get.rb
loquor-1.9.0 lib/loquor/http_actions/get.rb
loquor-1.8.0 lib/loquor/http_actions/get.rb
loquor-1.7.0 lib/loquor/http_actions/get.rb
loquor-1.6.0 lib/loquor/http_actions/get.rb
loquor-1.5.0 lib/loquor/http_actions/get.rb
loquor-1.4.0 lib/loquor/http_actions/get.rb
loquor-1.3.0 lib/loquor/http_actions/get.rb