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

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

Defined Under Namespace

Classes: InvalidDescriptionError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dsl_method, called_from, *args, &block) ⇒ MethodCall

Returns a new instance of MethodCall.



15
16
17
18
19
# File 'lib/dsl_compose/interpreter/execution/method_calls/method_call.rb', line 15

def initialize dsl_method, called_from, *args, &block
  @dsl_method = dsl_method
  @called_from = called_from
  @arguments = Arguments.new(dsl_method.arguments, called_from, *args)
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



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

def arguments
  @arguments
end

#called_fromObject (readonly)

Returns the value of attribute called_from.



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

def called_from
  @called_from
end

#dsl_methodObject (readonly)

Returns the value of attribute dsl_method.



11
12
13
# File 'lib/dsl_compose/interpreter/execution/method_calls/method_call.rb', line 11

def dsl_method
  @dsl_method
end

Instance Method Details

#add_parser_usage_note(note) ⇒ Object

the parser can provide usage notes for how this dsl is being used, these are used to generate documentation



33
34
35
36
37
38
39
40
# File 'lib/dsl_compose/interpreter/execution/method_calls/method_call.rb', line 33

def add_parser_usage_note note
  unless note.is_a?(String) && note.strip.length > 0
    raise InvalidDescriptionError.new("The parser usage description `#{note}` is invalid, it must be of type string and have length greater than 0", @called_from)
  end

  @parser_usage_notes ||= []
  @parser_usage_notes << note.strip
end

#method_nameObject



21
22
23
# File 'lib/dsl_compose/interpreter/execution/method_calls/method_call.rb', line 21

def method_name
  @dsl_method.name
end

#parser_usage_notesObject

return the list of notes which describe how the parsers are using this DSL



43
44
45
46
# File 'lib/dsl_compose/interpreter/execution/method_calls/method_call.rb', line 43

def parser_usage_notes
  @parser_usage_notes ||= []
  @parser_usage_notes
end

#to_hObject



25
26
27
28
29
# File 'lib/dsl_compose/interpreter/execution/method_calls/method_call.rb', line 25

def to_h
  {
    arguments: @arguments.to_h
  }
end