languages/ruby/lib/oso/polar/query.rb
def register_call(attribute, call_id:, instance:, args:) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
        return if calls.key?(call_id)

        instance = host.to_ruby(instance)
        if args.nil?
          result = instance.__send__(attribute)
        else
          args = args.map { |a| host.to_ruby(a) }
          result = instance.__send__(attribute, *args)
        end
        result = [result].to_enum unless result.is_a? Enumerator # Call must be a generator.
        calls[call_id] = result.lazy
      rescue ArgumentError, NoMethodError
        raise InvalidCallError
      end
# Register a Ruby method call, wrapping the call result in a generator if
# it isn't already one.
#
# @param method [#to_sym]
# @param call_id [Integer]
# @param instance [Hash<String, Object>]
# @param args [Array<Hash>]
# @raise [InvalidCallError] if the method doesn't exist on the instance or
#   the args passed to the method are invalid.
Register a Ruby method call, wrapping the call result in a generator if
it isn't already one.
Register a Ruby method call wrapping the call result in a generator if it isn ' t already one .
def register_call(attribute, call_id:, instance:, args:) 
        return if calls.key?(call_id)
        instance = host.to_ruby(instance)
        if args.nil?
          result = instance.__send__(attribute)
        else
          args = args.map { |a| host.to_ruby(a) }
          result = instance.__send__(attribute, *args)
        end
        result = [result].to_enum unless result.is_a? Enumerator 
        calls[call_id] = result.lazy
      rescue ArgumentError, NoMethodError
        raise InvalidCallError
      end
def register_call ( attribute , call_id : , instance : , args : ) return if calls . key? ( call_id ) instance = host . to_ruby ( instance ) if args . nil? result = instance . __send__ ( attribute ) else args = args . map { | a | host . to_ruby ( a ) } result = instance . __send__ ( attribute , * args ) end result = [ result ] . to_enum unless result . is_a? Enumerator calls [ call_id ] = result . lazy rescue ArgumentError , NoMethodError raise InvalidCallError end
Register a Ruby method call, wrapping the call result in a generator if
it isn't already one.
Register a Ruby method call wrapping the call result in a generator if it isn ' t already one .
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength # Call must be a generator.
[InvalidCallError] if the method doesn't exist on the instance or the args passed to the method are invalid.
[ InvalidCallError ] if the method doesn ' t exist on the instance or the args passed to the method are invalid .
attribute
call_id
instance
args
None