Class: Lightstreamer::SubscriptionItemData
- Inherits:
-
Object
- Object
- Lightstreamer::SubscriptionItemData
- Defined in:
- lib/lightstreamer/subscription_item_data.rb
Overview
Helper class used by Subscription to process incoming item data according to the four different subscription modes.
Instance Attribute Summary collapse
-
#data ⇒ Hash, ...
The current item data.
Instance Method Summary collapse
-
#process_new_command_data(new_data) ⇒ Object
Processes new data for the ‘:command` subscription mode.
-
#process_new_distinct_data(new_data) ⇒ Object
Processes new data for the ‘:distinct` subscription mode.
-
#process_new_merge_data(new_data) ⇒ Object
Processes new data for the ‘:merge` subscription mode.
-
#process_new_raw_data(new_data) ⇒ Object
Processes new data for the ‘:raw` subscription mode.
-
#set_data(new_data, mode) ⇒ Object
Explicitly sets this item data.
Instance Attribute Details
#data ⇒ Hash, ...
The current item data. Item data is a hash for all subscription modes except ‘:command`, for which it is an array.
10 11 12 |
# File 'lib/lightstreamer/subscription_item_data.rb', line 10 def data @data end |
Instance Method Details
#process_new_command_data(new_data) ⇒ Object
Processes new data for the ‘:command` subscription mode.
28 29 30 31 32 33 34 35 |
# File 'lib/lightstreamer/subscription_item_data.rb', line 28 def process_new_command_data(new_data) @data ||= [] key = row_key new_data command = new_data.delete(:command) || new_data.delete('command') send "process_#{command.to_s.downcase}_command", key, new_data end |
#process_new_distinct_data(new_data) ⇒ Object
Processes new data for the ‘:distinct` subscription mode.
40 41 42 |
# File 'lib/lightstreamer/subscription_item_data.rb', line 40 def process_new_distinct_data(new_data) @data = new_data end |
#process_new_merge_data(new_data) ⇒ Object
Processes new data for the ‘:merge` subscription mode.
47 48 49 50 |
# File 'lib/lightstreamer/subscription_item_data.rb', line 47 def process_new_merge_data(new_data) @data ||= {} @data.merge! new_data end |
#process_new_raw_data(new_data) ⇒ Object
Processes new data for the ‘:raw` subscription mode.
55 56 57 |
# File 'lib/lightstreamer/subscription_item_data.rb', line 55 def process_new_raw_data(new_data) @data = new_data end |
#set_data(new_data, mode) ⇒ Object
Explicitly sets this item data. See Lightstreamer::Subscription#set_item_data for details.
16 17 18 19 20 21 22 23 |
# File 'lib/lightstreamer/subscription_item_data.rb', line 16 def set_data(new_data, mode) raise ArgumentError, "Data can't be set unless mode is :command or :merge" unless %i[command merge].include? mode raise ArgumentError, 'Data must be a hash when in merge mode' if mode == :merge && !new_data.is_a?(Hash) validate_rows new_data if mode == :command @data = new_data.dup end |