Class: Arrow::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/arrow/function.rb

Instance Method Summary collapse

Instance Method Details

#execute(args, options = nil, context = nil) ⇒ Object Also known as: call



21
22
23
24
# File 'lib/arrow/function.rb', line 21

def execute(args, options=nil, context=nil)
  options = resolve_options(options)
  execute_raw(args, options, context)
end

#execute_rawObject



20
# File 'lib/arrow/function.rb', line 20

alias_method :execute_raw, :execute

#resolve_options(options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/arrow/function.rb', line 27

def resolve_options(options)
  return nil if options.nil?
  return options if options.is_a?(FunctionOptions)

  arrow_options_class = options_type&.to_class
  if arrow_options_class
    if arrow_options_class.respond_to?(:try_convert)
      arrow_options = arrow_options_class.try_convert(options)
      return arrow_options if arrow_options
    end
    arrow_options = (default_options || arrow_options_class.new)
  else
    arrow_options = default_options
  end
  return arrow_options if arrow_options.nil?

  options.each do |key, value|
    setter = :"#{key}="
    next unless arrow_options.respond_to?(setter)
    arrow_options.__send__(setter, value)
  end
  arrow_options
end