Sha256: e3e117eee6f97ac8a68f8f6954ce6b0e90dccff46bb7164674b1e6d1b9b188e7

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'nrser/refinements'

using NRSER

module QB 
module Util 

module Interop
  class << self
    
    # @todo Document receive method.
    # 
    # @param [type] arg_name
    #   @todo Add name param description.
    # 
    # @return [return_type]
    #   @todo Document return value.
    # 
    def receive      
      # method body
      yaml = $stdin.read
      
      File.open('./receive.log', 'w') { |f|
        f.write yaml
      }
      
      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 # #receive
    
  end # class << self
end # module Interop

end # module Util
end # module QB

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qb-0.1.78 lib/qb/util/interop.rb