Class: Gapic::Presenters::MessagePresenter

Inherits:
Object
  • Object
show all
Includes:
Helpers::NamespaceHelper
Defined in:
lib/gapic/presenters/message_presenter.rb

Overview

A presenter for proto messages.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::NamespaceHelper

#ensure_absolute_namespace, #fix_namespace, #ruby_namespace, #ruby_namespace_for_address

Constructor Details

#initialize(api, message) ⇒ MessagePresenter

Returns a new instance of MessagePresenter.

Parameters:



36
37
38
39
40
# File 'lib/gapic/presenters/message_presenter.rb', line 36

def initialize api, message
  @api = api
  @message = message
  @type = "message"
end

Instance Attribute Details

#typeString (readonly)

Returns String representation of this presenter type.

Returns:

  • (String)

    String representation of this presenter type.



30
31
32
# File 'lib/gapic/presenters/message_presenter.rb', line 30

def type
  @type
end

Instance Method Details

#default_valueObject



54
55
56
# File 'lib/gapic/presenters/message_presenter.rb', line 54

def default_value
  "{}"
end

#doc_descriptionObject



50
51
52
# File 'lib/gapic/presenters/message_presenter.rb', line 50

def doc_description
  @message.docs_leading_comments
end

#doc_typesObject



46
47
48
# File 'lib/gapic/presenters/message_presenter.rb', line 46

def doc_types
  type_name_full
end

#fieldsObject



62
63
64
# File 'lib/gapic/presenters/message_presenter.rb', line 62

def fields
  @fields = @message.fields.map { |f| FieldPresenter.new @api, @message, f }
end

#is_deprecated?Boolean

Returns Whether the message is marked as deprecated.

Returns:

  • (Boolean)

    Whether the message is marked as deprecated.



77
78
79
# File 'lib/gapic/presenters/message_presenter.rb', line 77

def is_deprecated?
  @message.is_deprecated?
end

#nameObject



42
43
44
# File 'lib/gapic/presenters/message_presenter.rb', line 42

def name
  @message.name
end

#nested_enumsObject



66
67
68
# File 'lib/gapic/presenters/message_presenter.rb', line 66

def nested_enums
  @nested_enums ||= @message.nested_enums.map { |e| EnumPresenter.new e }
end

#nested_messagesObject



70
71
72
# File 'lib/gapic/presenters/message_presenter.rb', line 70

def nested_messages
  @nested_messages ||= @message.nested_messages.map { |m| MessagePresenter.new @api, m }
end

#type_name_fullObject



58
59
60
# File 'lib/gapic/presenters/message_presenter.rb', line 58

def type_name_full
  message_ruby_type @message
end