Class: Euston::Websites::ApiCommandRequestParsing::DiscreteParser

Inherits:
AbstractParser
  • Object
show all
Defined in:
lib/euston-websites/api_command_request_parsing/discrete_parser.rb

Instance Method Summary collapse

Methods inherited from AbstractParser

#parse

Constructor Details

#initialize(request, params, command_type, command_id = nil) ⇒ DiscreteParser

Returns a new instance of DiscreteParser.



5
6
7
8
9
# File 'lib/euston-websites/api_command_request_parsing/discrete_parser.rb', line 5

def initialize request, params, command_type, command_id = nil
  super request
  @command_id = command_id || params[:id]
  @command_type = command_type
end

Instance Method Details

#transform_hash_to_commands(hash) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/euston-websites/api_command_request_parsing/discrete_parser.rb', line 11

def transform_hash_to_commands hash
  hash = hash.recursive__symbolize__keys!

  callback :preparing_hash, hash

  command = @command_type.new hash
  command.id = @command_id
  command
end