Module: Grape::DSL::Configuration::ClassMethods
- Includes:
- Settings
- Defined in:
- lib/grape/dsl/configuration.rb
Instance Attribute Summary collapse
-
#logger(logger = nil) ⇒ Object
Set or retrive the configured logger.
Attributes included from Settings
#inheritable_setting, #top_level_setting
Instance Method Summary collapse
-
#desc(description, options = {}) { ... } ⇒ Object
Add a description to the next namespace or function.
- #description_field(field, value = nil) ⇒ Object
- #unset_description_field(field) ⇒ Object
Methods included from Settings
#api_class_setting, #get_or_set, #global_setting, #namespace_end, #namespace_inheritable, #namespace_inheritable_to_nil, #namespace_setting, #namespace_stackable, #namespace_start, #route_end, #route_setting, #unset, #unset_api_class_setting, #unset_global_setting, #unset_namespace_inheritable, #unset_namespace_setting, #unset_namespace_stackable, #unset_route_setting, #within_namespace
Instance Attribute Details
#logger(logger = nil) ⇒ Object
Set or retrive the configured logger. If none was configured, this method will create a new one, logging to stdout.
16 17 18 19 20 21 22 |
# File 'lib/grape/dsl/configuration.rb', line 16 def logger(logger = nil) if logger global_setting(:logger, logger) else global_setting(:logger) || global_setting(:logger, Logger.new($stdout)) end end |
Instance Method Details
#desc(description, options = {}) { ... } ⇒ Object
Add a description to the next namespace or function.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/grape/dsl/configuration.rb', line 58 def desc(description, = {}, &config_block) if block_given? config_class = Grape::DSL::Configuration.desc_container config_class.configure do description description end config_class.configure(&config_block) unless .empty? warn '[DEPRECATION] Passing a options hash and a block to `desc` is deprecated. Move all hash options to block.' end = config_class.settings else = .merge(description: description) end namespace_setting :description, route_setting :description, end |
#description_field(field, value = nil) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/grape/dsl/configuration.rb', line 79 def description_field(field, value = nil) if value description = route_setting(:description) description ||= route_setting(:description, {}) description[field] = value else description = route_setting(:description) description[field] if description end end |
#unset_description_field(field) ⇒ Object
90 91 92 93 |
# File 'lib/grape/dsl/configuration.rb', line 90 def unset_description_field(field) description = route_setting(:description) description.delete(field) if description end |