Sha256: cbe539360d57c3de8ce248d6ffb02504f0787e9004d4cc09aa12711900804449

Contents?: true

Size: 405 Bytes

Versions: 1

Compression:

Stored size: 405 Bytes

Contents

require 'activesupport'

class JsonResponse

  attr_reader :status

  def initialize
    @status = false
    @data = {}
  end

  def serialize
    { :status => @status, :data => @data }.to_json
  end

  def to_js(callback)
    "#{callback}(#{serialize});"
  end

  def positive
    @status = true
  end

  def negative
    @status = false
  end

  def append(key, value)
    @data[key] = value
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json_response-1.0.1 lib/json_response.rb