Class: NiftyServices::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/nifty_services/configuration.rb

Constant Summary collapse

DEFAULT_I18N_NAMESPACE =
"nifty_services"
ERROR_RESPONSE_STATUS =
{
  :bad_request           => 400,
  :not_authorized        => 401,
  :forbidden             => 403,
  :not_found             => 404,
  :unprocessable_entity  => 422,
  # internal_server_error_error!
  :internal_server_error => 500,
  # keeping compatibility
  # internal_server_error!
  :internal_server       => 500,
  :not_implemented       => 501
}
SUCCESS_RESPONSE_STATUS =
{
  :ok => 200,
  :created => 201
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.



40
41
42
43
44
45
46
47
# File 'lib/nifty_services/configuration.rb', line 40

def initialize(options = {})
  @options = options
  @i18n_namespace = fetch(:i18n_namespace, default_i18n_namespace)
  @delete_record_method = :delete
  @update_record_method = :update
  @save_record_method = :save
  @logger = fetch(:logger, default_logger)
end

Instance Attribute Details

#delete_record_methodObject

Returns the value of attribute delete_record_method.



37
38
39
# File 'lib/nifty_services/configuration.rb', line 37

def delete_record_method
  @delete_record_method
end

#i18n_namespaceObject

Returns the value of attribute i18n_namespace.



37
38
39
# File 'lib/nifty_services/configuration.rb', line 37

def i18n_namespace
  @i18n_namespace
end

#loggerObject

Returns the value of attribute logger.



37
38
39
# File 'lib/nifty_services/configuration.rb', line 37

def logger
  @logger
end

#optionsObject (readonly)

Returns the value of attribute options.



35
36
37
# File 'lib/nifty_services/configuration.rb', line 35

def options
  @options
end

#save_record_methodObject

Returns the value of attribute save_record_method.



37
38
39
# File 'lib/nifty_services/configuration.rb', line 37

def save_record_method
  @save_record_method
end

#update_record_methodObject

Returns the value of attribute update_record_method.



37
38
39
# File 'lib/nifty_services/configuration.rb', line 37

def update_record_method
  @update_record_method
end

Class Method Details

.add_response_error_method(reason, status_code) ⇒ Object



30
31
32
# File 'lib/nifty_services/configuration.rb', line 30

def add_response_error_method(reason, status_code)
  ERROR_RESPONSE_STATUS[reason.to_sym] = status_code.to_i
end

.response_errors_listObject



26
27
28
# File 'lib/nifty_services/configuration.rb', line 26

def response_errors_list
  ERROR_RESPONSE_STATUS
end