Sha256: 808a4db13e9f183525aa34ad053ce500a2185582ed13fe7788e319822e728afb

Contents?: true

Size: 463 Bytes

Versions: 4

Compression:

Stored size: 463 Bytes

Contents

require 'alegra/formatters/underscore_formatter'
module Alegra
  class Response
    attr_reader :body, :formatter

    def initialize(body, formatter_class_name='UnderscoreFormatter')
      @body = JSON.parse(body)
      @formatter = Object.const_get("Alegra::Formatters::#{ formatter_class_name }").new
    end

    def call(options={})
      if options[:none]
        JSON.parse(body)
      else
        formatter.call(content: body)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alegra-0.1.2.3 lib/alegra/response.rb
alegra-0.1.2.2 lib/alegra/response.rb
alegra-0.1.2.1 lib/alegra/response.rb
alegra-0.1.2 lib/alegra/response.rb