Class: JSONAPI::ConfigManager::Config
- Inherits:
-
Object
- Object
- JSONAPI::ConfigManager::Config
- Defined in:
- lib/easy/jsonapi/config_manager/config.rb
Overview
User configurations for the gem
Instance Attribute Summary collapse
-
#allow_client_ids ⇒ Object
readonly
Returns the value of attribute allow_client_ids.
-
#required_document_members ⇒ Object
readonly
Returns the value of attribute required_document_members.
-
#required_headers ⇒ Object
readonly
Returns the value of attribute required_headers.
-
#required_query_params ⇒ Object
readonly
Returns the value of attribute required_query_params.
Instance Method Summary collapse
-
#default? ⇒ TrueClass | FalseClass
Performancewise, configs are all initialized as a startup cost, to change them you need to restart the server.
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 |
# File 'lib/easy/jsonapi/config_manager/config.rb', line 12 def initialize @allow_client_ids = false @default = true end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object (private)
Only used if implementing Item directly.
dynamically creates accessor methods for instance variables
created in the initialize
37 38 39 40 41 |
# File 'lib/easy/jsonapi/config_manager/config.rb', line 37 def method_missing(method_name, *args, &block) super unless READER_METHODS.include?(method_name.to_s[0..-2].to_sym) instance_variable_set("@#{method_name}"[0..-2].to_sym, args[0]) @default = false end |
Instance Attribute Details
#allow_client_ids ⇒ Object (readonly)
Returns the value of attribute allow_client_ids.
9 10 11 |
# File 'lib/easy/jsonapi/config_manager/config.rb', line 9 def allow_client_ids @allow_client_ids end |
#required_document_members ⇒ Object (readonly)
Returns the value of attribute required_document_members.
9 10 11 |
# File 'lib/easy/jsonapi/config_manager/config.rb', line 9 def required_document_members @required_document_members end |
#required_headers ⇒ Object (readonly)
Returns the value of attribute required_headers.
9 10 11 |
# File 'lib/easy/jsonapi/config_manager/config.rb', line 9 def required_headers @required_headers end |
#required_query_params ⇒ Object (readonly)
Returns the value of attribute required_query_params.
9 10 11 |
# File 'lib/easy/jsonapi/config_manager/config.rb', line 9 def required_query_params @required_query_params end |
Instance Method Details
#default? ⇒ TrueClass | FalseClass
Performancewise, configs are all initialized as a startup cost, to change them you need to
restart the server. As a result of this, the #default? is used to process a request
faster if user-defined configs do not need to be checked when screening http requests.
Because @default is set to false upon config assignment (see #method missing in Config),
this allows the a user to potentially make the middleware screening less performant than necessary
by assigning config values to the default values, or assigning values to something not default,
and then assigning config values to the default again. If used as intended, however, this should make
the middleware screening faster.
26 27 28 |
# File 'lib/easy/jsonapi/config_manager/config.rb', line 26 def default? @default end |