class Amber::Switch::Content::Json

Public Class Methods

new(data = {}) click to toggle source
Calls superclass method Amber::Switch::Content::new
# File lib/amber/switch/content/json.rb, line 4
def initialize(data = {})
  super Amber::Switch::Content::JSON_CONTENT, data
end

Public Instance Methods

data=(data) click to toggle source
Calls superclass method Amber::Switch::Content#data=
# File lib/amber/switch/content/json.rb, line 8
def data=(data)
  if data.is_a? Hash
    super
  end
end
deserialize(data) click to toggle source
# File lib/amber/switch/content/json.rb, line 23
def deserialize(data)
  if data.is_a? String
    begin
      return JSON.parse data
    rescue Exception => e
      p e
    end
  end
  {}
end
serialize(data) click to toggle source
# File lib/amber/switch/content/json.rb, line 14
def serialize(data)
  begin
    return JSON.generate data
  rescue Exception => e
    p e
  end
  ""
end