Class: Gapic::Presenters::FieldPresenter
Overview
A presenter for proto fields.
Instance Method Summary
collapse
#fix_namespace, #ruby_namespace, #ruby_namespace_for_address
Constructor Details
#initialize(api, message, field) ⇒ FieldPresenter
Returns a new instance of FieldPresenter.
28
29
30
31
32
|
# File 'lib/gapic/presenters/field_presenter.rb', line 28
def initialize api, message, field
@api = api
@message = message
@field = field
end
|
Instance Method Details
#as_kwarg(value: nil) ⇒ Object
61
62
63
|
# File 'lib/gapic/presenters/field_presenter.rb', line 61
def as_kwarg value: nil
"#{name}: #{value || name}"
end
|
#default_value ⇒ Object
55
56
57
58
59
|
# File 'lib/gapic/presenters/field_presenter.rb', line 55
def default_value
single = default_singular_value
return "[#{single}]" if @field.repeated? && !@field.map?
single
end
|
#doc_attribute_type ⇒ Object
42
43
44
45
|
# File 'lib/gapic/presenters/field_presenter.rb', line 42
def doc_attribute_type
mode = @field.output_only? ? "r" : "rw"
"@!attribute [#{mode}] #{@field.name}"
end
|
#doc_description ⇒ Object
51
52
53
|
# File 'lib/gapic/presenters/field_presenter.rb', line 51
def doc_description
@field.
end
|
#doc_types ⇒ Object
38
39
40
|
# File 'lib/gapic/presenters/field_presenter.rb', line 38
def doc_types
field_doc_types @field, false
end
|
#enum? ⇒ Boolean
79
80
81
|
# File 'lib/gapic/presenters/field_presenter.rb', line 79
def enum?
@field.enum?
end
|
#map? ⇒ Boolean
87
88
89
|
# File 'lib/gapic/presenters/field_presenter.rb', line 87
def map?
@field.map?
end
|
#message? ⇒ Boolean
75
76
77
|
# File 'lib/gapic/presenters/field_presenter.rb', line 75
def message?
@field.message?
end
|
#name ⇒ Object
34
35
36
|
# File 'lib/gapic/presenters/field_presenter.rb', line 34
def name
@field.name
end
|
#output_doc_types ⇒ Object
47
48
49
|
# File 'lib/gapic/presenters/field_presenter.rb', line 47
def output_doc_types
field_doc_types @field, true
end
|
#repeated? ⇒ Boolean
83
84
85
|
# File 'lib/gapic/presenters/field_presenter.rb', line 83
def repeated?
@field.repeated?
end
|
#type_name ⇒ Object
TODO: remove, only used in tests
66
67
68
|
# File 'lib/gapic/presenters/field_presenter.rb', line 66
def type_name
@field.type_name
end
|
#type_name_full ⇒ Object
70
71
72
73
|
# File 'lib/gapic/presenters/field_presenter.rb', line 70
def type_name_full
return nil if type_name.blank?
ruby_namespace @api, type_name
end
|