Class: RubyRabbitmqJanus::Tools::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/rrj/tools/replaces/type.rb

Overview

Class for converting elements given by apps to this gem an type conform to request sending

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Type

Initialize an object for cast a type to data given by app

Parameters:

  • request (Hash)

    Request parsing before sending to RabbitMQ/Janus



16
17
18
19
# File 'lib/rrj/tools/replaces/type.rb', line 16

def initialize(request)
  @request = request
  @key = @data = nil
end

Instance Method Details

#convert(key, option = {}) ⇒ Object

Return an data with a type corresponding to string in request

Parameters:

  • key (String)

    Key testing

  • option (Hash) (defaults to: {})

    Datas sending by user and adding/replace in request

Returns:

  • data with good type for JSON format



27
28
29
30
31
# File 'lib/rrj/tools/replaces/type.rb', line 27

def convert(key, option = {})
  @key = key
  @data = option[@key] if option.key?(@key)
  convert_data
end