lib/hanami/action/configuration.rb in hanami-controller-2.0.0.alpha2 vs lib/hanami/action/configuration.rb in hanami-controller-2.0.0.alpha3
- old
+ new
@@ -56,11 +56,11 @@
# @return [Hash{Exception=>Integer}]
#
# @see handled_exceptions=
#
# @since 0.2.0
- setting :handled_exceptions, {}
+ setting :handled_exceptions, default: {}
# Specifies how to handle exceptions with an HTTP status
#
# Raised exceptions will return the corresponding HTTP status
#
@@ -120,11 +120,11 @@
#
# @see format
# @see formats=
#
# @since 0.2.0
- setting :formats, DEFAULT_FORMATS.dup
+ setting :formats, default: DEFAULT_FORMATS.dup
# Registers a MIME type to format mapping
#
# @param hash [Hash{Symbol=>String}] format symbols as keys and the MIME
# type strings must as values
@@ -209,13 +209,13 @@
# @return [Symbol] format
#
# @see default_request_format=
#
# @since 0.5.0
- setting :default_request_format do |format|
+ setting :default_request_format, constructor: -> format {
Utils::Kernel.Symbol(format) unless format.nil?
- end
+ }
# @!method default_response_format=(format)
#
# Sets a format to be used for all responses regardless of the request
# type.
@@ -241,13 +241,13 @@
# @return [Symbol] format
#
# @see default_request_format=
#
# @since 0.5.0
- setting :default_response_format do |format|
+ setting :default_response_format, constructor: -> format {
Utils::Kernel.Symbol(format) unless format.nil?
- end
+ }
# @!method default_charset=(charset)
#
# Sets a charset (character set) as default fallback for all the requests
# without a strict requirement for the charset.
@@ -297,13 +297,11 @@
# @return [Hash{String=>String}] the headers
#
# @since 0.4.0
#
# @see default_headers=
- setting :default_headers, {} do |headers|
- headers.compact
- end
+ setting :default_headers, default: {}, constructor: -> headers { headers.compact }
# @!method cookies=(cookie_options)
#
# Sets default cookie options for all responses.
#
@@ -330,15 +328,15 @@
# @return [Hash{Symbol=>String}]
#
# @since 0.4.0
#
# @see cookies=
- setting :cookies, {} do |cookie_options|
+ setting :cookies, default: {}, constructor: -> cookie_options {
# Call `to_h` here to permit `ApplicationConfiguration::Cookies` object to be
# provided when application actions are configured
cookie_options.to_h.compact
- end
+ }
# @!method root_directory=(dir)
#
# Sets the the for the public directory, which is used for file downloads.
# This must be an existent directory.
@@ -362,15 +360,15 @@
# @see root_directory=
#
# @since 1.0.0
#
# @api private
- setting :root_directory do |dir|
+ setting :root_directory, constructor: -> dir {
dir ||= Dir.pwd
Pathname(dir).realpath
- end
+ }
# Default public directory
#
# This serves as the root directory for file downloads
#
@@ -391,10 +389,10 @@
#
# @return [void]
#
# @see root_directory
# @see public_directory
- setting :public_directory, DEFAULT_PUBLIC_DIRECTORY
+ setting :public_directory, default: DEFAULT_PUBLIC_DIRECTORY
# Returns the configured public directory, appended onto the root directory.
#
# @return [String] the fill directory path
#