Class: Apipie::Configuration
- Inherits:
-
Object
- Object
- Apipie::Configuration
- Extended by:
- Forwardable
- Defined in:
- lib/apipie/configuration.rb
Instance Attribute Summary collapse
-
#action_on_non_validated_keys ⇒ Object
Returns the value of attribute action_on_non_validated_keys.
-
#api_action_matcher ⇒ Object
An object that responds to a ‘.call(controller)` method responsible for matching the correct controller action.
-
#api_base_url ⇒ Object
Returns the value of attribute api_base_url.
-
#api_controllers_matcher ⇒ Object
matcher to be used in Dir.glob to find controllers to be reloaded e.g.
-
#api_routes ⇒ Object
specify routes if used router differ from default e.g.
-
#app_info ⇒ Object
Returns the value of attribute app_info.
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#authenticate ⇒ Object
Returns the value of attribute authenticate.
-
#authorize ⇒ Object
Returns the value of attribute authorize.
- #cache_dir ⇒ Object
-
#checksum_path ⇒ Object
Returns the value of attribute checksum_path.
-
#compress_examples ⇒ Object
Returns the value of attribute compress_examples.
-
#copyright ⇒ Object
Returns the value of attribute copyright.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#default_locale ⇒ Object
Returns the value of attribute default_locale.
-
#default_version ⇒ Object
Returns the value of attribute default_version.
-
#disqus_shortname ⇒ Object
Returns the value of attribute disqus_shortname.
-
#doc_base_url ⇒ Object
Returns the value of attribute doc_base_url.
-
#doc_path ⇒ Object
Returns the value of attribute doc_path.
-
#force_dsl ⇒ Object
writeonly
if there is not obvious reason why the DSL should be turned on (no validations, cache turned on etc.), it’s disabled to avoid unneeded allocation.
- #generated_doc_disclaimer ⇒ Object
-
#ignore_allow_blank_false ⇒ Object
Returns the value of attribute ignore_allow_blank_false.
- #ignored ⇒ Object
- #ignored_by_recorder ⇒ Object
-
#languages ⇒ Object
Returns the value of attribute languages.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#link_extension ⇒ Object
Returns the value of attribute link_extension.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#markup ⇒ Object
Returns the value of attribute markup.
-
#namespaced_resources ⇒ Object
(also: #namespaced_resources?)
Returns the value of attribute namespaced_resources.
-
#persist_show_in_doc ⇒ Object
Returns the value of attribute persist_show_in_doc.
-
#process_params ⇒ Object
Returns the value of attribute process_params.
-
#record ⇒ Object
Returns the value of attribute record.
-
#reload_controllers ⇒ Object
writeonly
set to true if you want to reload the controllers at each refresh of the documentation.
-
#required_by_default ⇒ Object
(also: #required_by_default?)
Returns the value of attribute required_by_default.
-
#routes_formatter ⇒ Object
a object responsible for transforming the routes loaded from Rails to a form to be used in the documentation, when using the ‘api!` keyword.
-
#show_all_examples ⇒ Object
Returns the value of attribute show_all_examples.
-
#translate ⇒ Object
Returns the value of attribute translate.
-
#update_checksum ⇒ Object
Returns the value of attribute update_checksum.
-
#use_cache ⇒ Object
(also: #use_cache?)
set to true if you want to use pregenerated documentation cache and avoid generating the documentation on runtime (useful for production environment).
-
#validate ⇒ Object
(also: #validate?)
Returns the value of attribute validate.
-
#validate_key ⇒ Object
(also: #validate_key?)
Returns the value of attribute validate_key.
-
#validate_presence ⇒ Object
(also: #validate_presence?)
Returns the value of attribute validate_presence.
-
#validate_value ⇒ Object
(also: #validate_value?)
Returns the value of attribute validate_value.
-
#version_in_url ⇒ Object
Returns the value of attribute version_in_url.
Instance Method Summary collapse
- #force_dsl? ⇒ Boolean
- #generator ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #process_value? ⇒ Boolean
- #reload_controllers? ⇒ Boolean
- #swagger ⇒ Object
- #use_disqus? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/apipie/configuration.rb', line 161 def initialize @markup = Apipie::Markup::RDoc.new @app_name = "Another API" @app_info = ActiveSupport::HashWithIndifferentAccess.new @copyright = nil @validate = :implicitly @validate_value = true @validate_presence = true @validate_key = false @action_on_non_validated_keys = :raise @required_by_default = false @api_base_url = ActiveSupport::HashWithIndifferentAccess.new @api_action_matcher = proc { |controller| controller.params[:action] } @doc_base_url = "/apipie" @layout = "apipie/apipie" @disqus_shortname = nil @default_version = "1.0" @debug = false @ignore_allow_blank_false = false @version_in_url = true @namespaced_resources = false @doc_path = "doc" @process_params = false @checksum_path = [@doc_base_url, '/api/'] @update_checksum = false @link_extension = ".html" @record = false @languages = [] @default_locale = 'en' @locale = lambda { |locale| @default_locale } @translate = lambda { |str, locale| str } @persist_show_in_doc = false @routes_formatter = RoutesFormatter.new end |
Instance Attribute Details
#action_on_non_validated_keys ⇒ Object
Returns the value of attribute action_on_non_validated_keys.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def action_on_non_validated_keys @action_on_non_validated_keys end |
#api_action_matcher ⇒ Object
An object that responds to a ‘.call(controller)` method responsible for matching the correct controller action
35 36 37 |
# File 'lib/apipie/configuration.rb', line 35 def api_action_matcher @api_action_matcher end |
#api_base_url ⇒ Object
Returns the value of attribute api_base_url.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def api_base_url @api_base_url end |
#api_controllers_matcher ⇒ Object
matcher to be used in Dir.glob to find controllers to be reloaded e.g.
"#{Rails.root}/app/controllers/api/*.rb"
31 32 33 |
# File 'lib/apipie/configuration.rb', line 31 def api_controllers_matcher @api_controllers_matcher end |
#api_routes ⇒ Object
specify routes if used router differ from default e.g.
Api::Engine.routes
51 52 53 |
# File 'lib/apipie/configuration.rb', line 51 def api_routes @api_routes end |
#app_info ⇒ Object
Returns the value of attribute app_info.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def app_info @app_info end |
#app_name ⇒ Object
Returns the value of attribute app_name.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def app_name @app_name end |
#authenticate ⇒ Object
Returns the value of attribute authenticate.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def authenticate @authenticate end |
#authorize ⇒ Object
Returns the value of attribute authorize.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def @authorize end |
#cache_dir ⇒ Object
93 94 95 |
# File 'lib/apipie/configuration.rb', line 93 def cache_dir @cache_dir ||= File.join(Rails.root, "public", "apipie-cache") end |
#checksum_path ⇒ Object
Returns the value of attribute checksum_path.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def checksum_path @checksum_path end |
#compress_examples ⇒ Object
Returns the value of attribute compress_examples.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def compress_examples @compress_examples end |
#copyright ⇒ Object
Returns the value of attribute copyright.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def copyright @copyright end |
#debug ⇒ Object
Returns the value of attribute debug.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def debug @debug end |
#default_locale ⇒ Object
Returns the value of attribute default_locale.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def default_locale @default_locale end |
#default_version ⇒ Object
Returns the value of attribute default_version.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def default_version @default_version end |
#disqus_shortname ⇒ Object
Returns the value of attribute disqus_shortname.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def disqus_shortname @disqus_shortname end |
#doc_base_url ⇒ Object
Returns the value of attribute doc_base_url.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def doc_base_url @doc_base_url end |
#doc_path ⇒ Object
Returns the value of attribute doc_path.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def doc_path @doc_path end |
#force_dsl=(value) ⇒ Object (writeonly)
if there is not obvious reason why the DSL should be turned on (no validations, cache turned on etc.), it’s disabled to avoid unneeded allocation. It you need the DSL for other reasons, you can force the activation.
101 102 103 |
# File 'lib/apipie/configuration.rb', line 101 def force_dsl=(value) @force_dsl = value end |
#generated_doc_disclaimer ⇒ Object
133 134 135 |
# File 'lib/apipie/configuration.rb', line 133 def generated_doc_disclaimer @generated_doc_disclaimer ||= "# DOC GENERATED AUTOMATICALLY: REMOVE THIS LINE TO PREVENT REGENERATING NEXT TIME" end |
#ignore_allow_blank_false ⇒ Object
Returns the value of attribute ignore_allow_blank_false.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def ignore_allow_blank_false @ignore_allow_blank_false end |
#ignored ⇒ Object
119 120 121 122 |
# File 'lib/apipie/configuration.rb', line 119 def ignored @ignored ||= [] @ignored.map(&:to_s) end |
#ignored_by_recorder ⇒ Object
110 111 112 113 |
# File 'lib/apipie/configuration.rb', line 110 def ignored_by_recorder @ignored_by_recorder ||= [] @ignored_by_recorder.map(&:to_s) end |
#languages ⇒ Object
Returns the value of attribute languages.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def languages @languages end |
#layout ⇒ Object
Returns the value of attribute layout.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def layout @layout end |
#link_extension ⇒ Object
Returns the value of attribute link_extension.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def link_extension @link_extension end |
#locale ⇒ Object
Returns the value of attribute locale.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def locale @locale end |
#markup ⇒ Object
Returns the value of attribute markup.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def markup @markup end |
#namespaced_resources ⇒ Object Also known as: namespaced_resources?
Returns the value of attribute namespaced_resources.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def namespaced_resources @namespaced_resources end |
#persist_show_in_doc ⇒ Object
Returns the value of attribute persist_show_in_doc.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def persist_show_in_doc @persist_show_in_doc end |
#process_params ⇒ Object
Returns the value of attribute process_params.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def process_params @process_params end |
#record ⇒ Object
Returns the value of attribute record.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def record @record end |
#reload_controllers=(value) ⇒ Object (writeonly)
set to true if you want to reload the controllers at each refresh of the documentation. It requires :api_controllers_matcher
to be set to work properly.
46 47 48 |
# File 'lib/apipie/configuration.rb', line 46 def reload_controllers=(value) @reload_controllers = value end |
#required_by_default ⇒ Object Also known as: required_by_default?
Returns the value of attribute required_by_default.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def required_by_default @required_by_default end |
#routes_formatter ⇒ Object
a object responsible for transforming the routes loaded from Rails to a form to be used in the documentation, when using the ‘api!` keyword. By default, it’s Apipie::RoutesFormatter. To customize the behaviour, one can inherit from from this class and override the methods as needed.
57 58 59 |
# File 'lib/apipie/configuration.rb', line 57 def routes_formatter @routes_formatter end |
#show_all_examples ⇒ Object
Returns the value of attribute show_all_examples.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def show_all_examples @show_all_examples end |
#translate ⇒ Object
Returns the value of attribute translate.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def translate @translate end |
#update_checksum ⇒ Object
Returns the value of attribute update_checksum.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def update_checksum @update_checksum end |
#use_cache ⇒ Object Also known as: use_cache?
set to true if you want to use pregenerated documentation cache and avoid generating the documentation on runtime (useful for production environment). You can generate the cache by running
rake apipie:cache
89 90 91 |
# File 'lib/apipie/configuration.rb', line 89 def use_cache @use_cache end |
#validate ⇒ Object Also known as: validate?
Returns the value of attribute validate.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def validate @validate end |
#validate_key ⇒ Object Also known as: validate_key?
Returns the value of attribute validate_key.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def validate_key @validate_key end |
#validate_presence ⇒ Object Also known as: validate_presence?
Returns the value of attribute validate_presence.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def validate_presence @validate_presence end |
#validate_value ⇒ Object Also known as: validate_value?
Returns the value of attribute validate_value.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def validate_value @validate_value end |
#version_in_url ⇒ Object
Returns the value of attribute version_in_url.
5 6 7 |
# File 'lib/apipie/configuration.rb', line 5 def version_in_url @version_in_url end |
Instance Method Details
#force_dsl? ⇒ Boolean
102 103 104 |
# File 'lib/apipie/configuration.rb', line 102 def force_dsl? @force_dsl end |
#generator ⇒ Object
20 21 22 |
# File 'lib/apipie/configuration.rb', line 20 def generator Apipie::Generator::Config.instance end |
#process_value? ⇒ Boolean
80 81 82 |
# File 'lib/apipie/configuration.rb', line 80 def process_value? @process_params end |
#reload_controllers? ⇒ Boolean
59 60 61 62 63 |
# File 'lib/apipie/configuration.rb', line 59 def reload_controllers? @reload_controllers = Rails.env.development? unless defined? @reload_controllers @reload_controllers && @api_controllers_matcher end |
#swagger ⇒ Object
16 17 18 |
# File 'lib/apipie/configuration.rb', line 16 def swagger Apipie::Generator::Swagger::Config.instance end |
#use_disqus? ⇒ Boolean
137 138 139 |
# File 'lib/apipie/configuration.rb', line 137 def use_disqus? !@disqus_shortname.blank? end |