Module: Swiftfake::FunctionDecorator

Defined in:
lib/swiftfake/function_decorator.rb

Instance Method Summary collapse

Instance Method Details

#args_store_appendObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/swiftfake/function_decorator.rb', line 19

def args_store_append
  store_name = args_store_name

  if arguments.count == 1
    "#{store_name}.append(#{arguments.first.name})"
  else
    arg_names = arguments.map(&:name).join(", ")
    tuple = "(#{arg_names})"
    "#{store_name}.append(#{tuple})"
  end
end

#args_store_declarationObject



31
32
33
# File 'lib/swiftfake/function_decorator.rb', line 31

def args_store_declaration
  "#{var_prefix} #{args_store_name} = [#{args_store_type}]()"
end

#call_countObject



7
8
9
# File 'lib/swiftfake/function_decorator.rb', line 7

def call_count
  "#{name}CallCount"
end

#call_count_declarationObject



11
12
13
# File 'lib/swiftfake/function_decorator.rb', line 11

def call_count_declaration
  "#{var_prefix} #{call_count} = 0"
end

#has_args?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/swiftfake/function_decorator.rb', line 15

def has_args?
  arguments.any?
end

#return_value_declarationObject



39
40
41
# File 'lib/swiftfake/function_decorator.rb', line 39

def return_value_declaration
  "return #{return_value_var_name}"
end

#return_value_store_declarationObject



43
44
45
# File 'lib/swiftfake/function_decorator.rb', line 43

def return_value_store_declaration
  "#{var_prefix} #{return_value_var_name} = #{return_value_initialized}"
end

#returns?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/swiftfake/function_decorator.rb', line 35

def returns?
  !return_value.nil?
end

#signatureObject



3
4
5
# File 'lib/swiftfake/function_decorator.rb', line 3

def signature
  "override #{full_name}"
end