Class: RubyRabbitmqJanus::Tools::Type

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Type

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

Parameters:

  • request (Hash)

    Request parsing before sending to RabbitMQ/Janus



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

def initialize(request)
  @request = request
  @key = @data = nil
rescue
  raise Errors::Tools::Type::Initializer
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



30
31
32
33
34
35
36
# File 'lib/rrj/tools/replaces/type.rb', line 30

def convert(key, option = {})
  @key = key
  @data = option[@key] if option.key?(@key)
  convert_data
rescue
  raise Errors::Tools::Type::Convert
end