Module: QB::Util::Interop

Defined in:
lib/qb/util/interop.rb

Class Method Summary collapse

Class Method Details

.receivereturn_type

TODO:

Document receive method.

Returns @todo Document return value.

Parameters:

  • arg_name (type)

    @todo Add name param description.

Returns:

  • (return_type)

    @todo Document return value.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/qb/util/interop.rb', line 19

def receive      
  # method body
  yaml = $stdin.read
  
  payload = YAML.load yaml
  
  data = payload.fetch 'data'
  method = payload.fetch 'method'
  args = payload['args'] || []
  kwds = payload['kwds'] || {}
  args << kwds.symbolize_keys unless kwds.empty?
  
  obj = if data.is_a?(Hash) && data.key?(NRSER::Meta::Props::CLASS_KEY)
    NRSER::Meta::Props.from_data data
  else
    data
  end
  
  result = obj.send method, *args
  
  $stdout.write result.to_yaml
  
end