Sha256: e667b09f3dbc3dcecaf9a9ba735bb706782d30d065434d1c1c07e7048c3bdd31

Contents?: true

Size: 646 Bytes

Versions: 17

Compression:

Stored size: 646 Bytes

Contents

# encoding: utf-8
require "logstash/json"

module LogStash::Api::AppHelpers

  def respond_with(data, options={})
    as     = options.fetch(:as, :json)
    pretty = params.has_key?("pretty")
    if as == :json
      content_type "application/json"
      LogStash::Json.dump(data, {:pretty => pretty})
    else
      content_type "text/plain"
      data.to_s
    end
  end

  def as_boolean(string)
    return true   if string == true   || string =~ (/(true|t|yes|y|1)$/i)
    return false  if string == false  || string.blank? || string =~ (/(false|f|no|n|0)$/i)
    raise ArgumentError.new("invalid value for Boolean: \"#{string}\"")
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
logstash-core-5.0.0.alpha4.snapshot3-java lib/logstash/api/app_helpers.rb
logstash-core-5.0.0.alpha4.snapshot2-java lib/logstash/api/app_helpers.rb
logstash-core-5.0.0.alpha4.snapshot1-java lib/logstash/api/app_helpers.rb
logstash-core-5.0.0.alpha3-java lib/logstash/api/app_helpers.rb
logstash-core-5.0.0.alpha3.snapshot8-java lib/logstash/api/app_helpers.rb
logstash-core-5.0.0.alpha3.snapshot7-java lib/logstash/api/app_helpers.rb
logstash-core-5.0.0.alpha3.snapshot6-java lib/logstash/api/app_helpers.rb
logstash-core-5.0.0.alpha3.snapshot5-java lib/logstash/api/lib/helpers/app_helpers.rb
logstash-core-5.0.0.alpha3.snapshot4-java lib/logstash/api/lib/helpers/app_helpers.rb
logstash-core-5.0.0.alpha3.snapshot2-java lib/logstash/api/lib/helpers/app_helpers.rb
logstash-core-5.0.0.alpha3.snapshot1-java lib/logstash/api/lib/helpers/app_helpers.rb
logstash-core-5.0.0.alpha2-java lib/logstash/api/lib/helpers/app_helpers.rb
logstash-core-5.0.0.alpha2.snapshot2-java lib/logstash/api/lib/helpers/app_helpers.rb
logstash-core-5.0.0.alpha2.snapshot1-java lib/logstash/api/lib/helpers/app_helpers.rb
logstash-core-5.0.0.alpha1-java lib/logstash/api/lib/helpers/app_helpers.rb
logstash-core-5.0.0.alpha1.snapshot2-java lib/logstash/api/lib/helpers/app_helpers.rb
logstash-core-5.0.0.alpha1.snapshot1-java lib/logstash/api/lib/helpers/app_helpers.rb