Class: LogStash::Filters::FixMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/filters/fix_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg_string, data_dictionary, session_dictionary) ⇒ FixMessage

Returns a new instance of FixMessage.



8
9
10
11
12
13
14
15
16
17
# File 'lib/logstash/filters/fix_message.rb', line 8

def initialize(msg_string, data_dictionary, session_dictionary)
  @session_dictionary = session_dictionary
  @data_dictionary = data_dictionary
  @msg_string = msg_string
  @type = quickfix.MessageUtils.getMessageType(msg_string)
  @unknown_fields = []
  @all_dictionaries = [@data_dictionary, @session_dictionary]

  super(msg_string, data_dictionary, false)
end

Instance Attribute Details

#all_dictionariesObject (readonly)

Returns the value of attribute all_dictionaries.



6
7
8
# File 'lib/logstash/filters/fix_message.rb', line 6

def all_dictionaries
  @all_dictionaries
end

#data_dictionaryObject (readonly)

Returns the value of attribute data_dictionary.



6
7
8
# File 'lib/logstash/filters/fix_message.rb', line 6

def data_dictionary
  @data_dictionary
end

#msg_stringObject (readonly)

Returns the value of attribute msg_string.



6
7
8
# File 'lib/logstash/filters/fix_message.rb', line 6

def msg_string
  @msg_string
end

#session_dictionaryObject (readonly)

Returns the value of attribute session_dictionary.



6
7
8
# File 'lib/logstash/filters/fix_message.rb', line 6

def session_dictionary
  @session_dictionary
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/logstash/filters/fix_message.rb', line 6

def type
  @type
end

#unknown_fieldsObject (readonly)

Returns the value of attribute unknown_fields.



6
7
8
# File 'lib/logstash/filters/fix_message.rb', line 6

def unknown_fields
  @unknown_fields
end

Instance Method Details

#to_hashObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/logstash/filters/fix_message.rb', line 19

def to_hash
  # TODO: This logic / parsing might make sense in quickfix-j / java world
  # Then, from here, we could inherit from quickfix.Message and call `JSON.parse(self.to_json)`
  # OR: Might want to move all this to ruby
  # dd = Hash.from_xml(load_fixture("FIX50SP1.xml")) || https://github.com/jnunemaker/crack
  header_msg  = field_map_to_hash(self.header)
  body_msg    = field_map_to_hash(self, type)
  trailer_msg = field_map_to_hash(self.trailer)

  header_msg.merge(body_msg).merge(trailer_msg)
end