Class: EnableTypeHandler

Inherits:
AbstractHandler show all
Defined in:
lib/hypertube-ruby-sdk/core/handler/enable_type_handler.rb

Instance Method Summary collapse

Methods inherited from AbstractHandler

#handle_command, #validate

Constructor Details

#initializeEnableTypeHandler

Returns a new instance of EnableTypeHandler.



7
8
9
# File 'lib/hypertube-ruby-sdk/core/handler/enable_type_handler.rb', line 7

def initialize
  @required_parameters_count = 1
end

Instance Method Details

#process(command) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hypertube-ruby-sdk/core/handler/enable_type_handler.rb', line 11

def process(command)
  validate(command, @required_parameters_count, self.class.name)

  type_cache = TypeCache.instance

  command.payload.each do |payload|
    if payload.is_a? String
      type_cache.cache_type(payload)
    elsif payload.is_a? Array
      payload.each do |type_to_enable|
        type_cache.cache_type(type_to_enable)
      end
    end
  end
  0
end