Module: RText::JsonInterface

Included in:
MessageHelper
Defined in:
lib/rtext/json_interface.rb

Overview

this module provides an abstract JSON interface; it is a global configuration point for JSON conversion in RText; use set_o2j_converter and set_j2o_converter to use other json implementations

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.set_j2o_converter(conv) ⇒ Object

set the j2o converter, a proc which takes json and returns an object



16
17
18
# File 'lib/rtext/json_interface.rb', line 16

def self.set_j2o_converter(conv)
  define_method(:json_to_object, conv)
end

.set_o2j_converter(conv) ⇒ Object

set the o2j converter, a proc which takes an object and returns json



11
12
13
# File 'lib/rtext/json_interface.rb', line 11

def self.set_o2j_converter(conv)
  define_method(:object_to_json, conv)
end

Instance Method Details

#json_to_object(json) ⇒ Object



24
25
26
# File 'lib/rtext/json_interface.rb', line 24

def json_to_object(json)
  JSON(json)
end

#object_to_json(obj) ⇒ Object



20
21
22
# File 'lib/rtext/json_interface.rb', line 20

def object_to_json(obj)
  JSON(obj)
end