Sha256: 3b7a1e21fcb1eb5253b7d39e93a0668074600c9e977e552c0ce993525b5ccefd

Contents?: true

Size: 441 Bytes

Versions: 8

Compression:

Stored size: 441 Bytes

Contents

class Simple::Httpd::BaseController
  def json(result)
    content_type :json
    generate_json(result)
  end

  private

  def generate_json(result)
    JSON.generate(result)
  end

  configure :development, :test do
    begin
      require "neatjson"
    rescue LoadError
      :nop
    end

    def generate_json(result)
      JSON.respond_to?(:neat_generate) ? JSON.neat_generate(result) : JSON.pretty_generate(result)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
simple-httpd-0.4.3 lib/simple/httpd/base_controller/json.rb
simple-httpd-0.4.2 lib/simple/httpd/base_controller/json.rb
simple-httpd-0.4.1 lib/simple/httpd/base_controller/json.rb
simple-httpd-0.4.0 lib/simple/httpd/base_controller/json.rb
simple-httpd-0.3.5 lib/simple/httpd/base_controller/json.rb
simple-httpd-0.3.4 lib/simple/httpd/base_controller/json.rb
simple-httpd-0.3.3 lib/simple/httpd/base_controller/json.rb
simple-httpd-0.3.1 lib/simple/httpd/base_controller/json.rb