Class: DSLCompose::Interpreter::Execution::MethodCalls

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl_compose/interpreter/execution/method_calls.rb,
lib/dsl_compose/interpreter/execution/method_calls/method_call.rb

Defined Under Namespace

Classes: MethodCall

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMethodCalls

Returns a new instance of MethodCalls.



9
10
11
# File 'lib/dsl_compose/interpreter/execution/method_calls.rb', line 9

def initialize
  @method_calls = []
end

Instance Attribute Details

#method_callsObject (readonly)

Returns the value of attribute method_calls.



7
8
9
# File 'lib/dsl_compose/interpreter/execution/method_calls.rb', line 7

def method_calls
  @method_calls
end

Instance Method Details

#add_method_call(dsl_method, called_from) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dsl_compose/interpreter/execution/method_calls.rb', line 17

def add_method_call(dsl_method, called_from, ...)
  # make sure we always have a variable which can be used in the exception message
  # set to nil first, so that if we get an exception while setting them
  # it wont break the error message generation
  dsl_method_name = nil
  dsl_method_name = dsl_method.name

  method_call = MethodCall.new(dsl_method, called_from, ...)
  @method_calls << method_call
  method_call
rescue => e
  raise e, "Error while executing method #{dsl_method_name}\n#{e.message}", e.backtrace
end

#method_called?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/dsl_compose/interpreter/execution/method_calls.rb', line 13

def method_called? method_name
  @method_calls.filter { |mc| mc.method_name == method_name }.any?
end

#method_calls_by_name(method_name) ⇒ Object



31
32
33
# File 'lib/dsl_compose/interpreter/execution/method_calls.rb', line 31

def method_calls_by_name method_name
  @method_calls.filter { |mc| mc.method_name == method_name }
end