Module: Rails::GraphQL::Helpers::WithDescription
Instance Method Summary collapse
-
#desc(value = nil) ⇒ Object
A getter or setter in the same function.
-
#description(namespace = nil, kind = nil) ⇒ Object
Return a description, by defined value or I18n.
-
#description=(value) ⇒ Object
Define and format description.
-
#description? ⇒ Boolean
Checks if a description was provided.
Instance Method Details
#desc(value = nil) ⇒ Object
A getter or setter in the same function
9 10 11 |
# File 'lib/rails/graphql/helpers/with_description.rb', line 9 def desc(value = nil) value.nil? ? description : (self.description = value) end |
#description(namespace = nil, kind = nil) ⇒ Object
Return a description, by defined value or I18n
23 24 25 26 27 28 |
# File 'lib/rails/graphql/helpers/with_description.rb', line 23 def description(namespace = nil, kind = nil) return @description if description? return unless GraphQL.config.enable_i18n_descriptions i18n_description(namespace, kind) end |
#description=(value) ⇒ Object
Define and format description
14 15 16 17 18 19 20 |
# File 'lib/rails/graphql/helpers/with_description.rb', line 14 def description=(value) if !value.nil? @description = value.to_s.presence&.strip_heredoc&.chomp elsif defined?(@description) @description = nil end end |
#description? ⇒ Boolean
Checks if a description was provided
31 32 33 |
# File 'lib/rails/graphql/helpers/with_description.rb', line 31 def description? defined?(@description) && !!@description end |