lib/hanami/view.rb in hanami-view-2.0.0.alpha2 vs lib/hanami/view.rb in hanami-view-2.0.0.alpha3
- old
+ new
@@ -54,13 +54,13 @@
#
# @param paths [String, Path, Array<String, Path>] the paths
#
# @api public
# @!scope class
- setting :paths do |paths|
+ setting :paths, constructor: -> paths {
Array(paths).map { |path| Path[path] }
- end
+ }
# @overload config.template=(name)
# Set the name of the template for rendering this view. Template name
# should be relative to the configured `paths`.
#
@@ -94,20 +94,20 @@
# A false or nil value will use no layout. Defaults to `nil`.
#
# @param name [String, FalseClass, nil] layout name, or false to indicate no layout
# @api public
# @!scope class
- setting :layout, false
+ setting :layout, default: false
# @overload config.layouts_dir=(dir)
# Set the name of the directory (within the configured `paths`) holding
# the layouts. Defaults to `"layouts"`
#
# @param dir [String] directory name
# @api public
# @!scope class
- setting :layouts_dir, "layouts"
+ setting :layouts_dir, default: "layouts"
# @overload config.scope=(scope_class)
# Set the scope class to use when rendering the view's template.
#
# Configuring a custom scope class allows you to provide extra behaviour
@@ -129,21 +129,21 @@
# @see View#call
#
# @param context [Hanami::View::Context] context object
# @api public
# @!scope class
- setting :default_context, Context.new.freeze
+ setting :default_context, default: Context.new.freeze
# @overload config.default_format=(format)
# Set the default format to use when rendering.
#
# Defaults to `:html`.
#
# @param format [Symbol]
# @api public
# @!scope class
- setting :default_format, :html
+ setting :default_format, default: :html
# @overload config.scope_namespace=(namespace)
# Set a namespace that will be searched when building scope classes.
#
# @param namespace [Module, Class]
@@ -160,11 +160,11 @@
# @see https://dry-rb.org/gems/dry-view/parts/
#
# @param part_builder [Class]
# @api public
# @!scope class
- setting :part_builder, PartBuilder
+ setting :part_builder, default: PartBuilder
# @overload config.scope_namespace=(namespace)
# Set a namespace that will be searched when building scope classes.
#
# @param namespace [Module, Class]
@@ -181,21 +181,21 @@
# @see https://dry-rb.org/gems/dry-view/scopes/
#
# @param scope_builder [Class]
# @api public
# @!scope class
- setting :scope_builder, ScopeBuilder
+ setting :scope_builder, default: ScopeBuilder
# @overload config.inflector=(inflector)
# Set an inflector to provide to the part_builder and scope_builder.
#
# Defaults to `Dry::Inflector.new`.
#
# @param inflector
# @api public
# @!scope class
- setting :inflector, Dry::Inflector.new
+ setting :inflector, default: Dry::Inflector.new
# @overload config.renderer_options=(options)
# A hash of options to pass to the template engine. Template engines are
# provided by Tilt; see Tilt's documentation for what options your
# template engine may support.
@@ -206,12 +206,12 @@
# @see https://github.com/rtomayko/tilt
#
# @param options [Hash] renderer options
# @api public
# @!scope class
- setting :renderer_options, DEFAULT_RENDERER_OPTIONS do |options|
+ setting :renderer_options, default: DEFAULT_RENDERER_OPTIONS, constructor: -> options {
DEFAULT_RENDERER_OPTIONS.merge(options.to_h).freeze
- end
+ }
# @overload config.renderer_engine_mapping=(mapping)
# A hash specifying the (Tilt-compatible) template engine class to use
# for a given format. Template engine detection is automatic based on
# format; use this setting only if you want to force a non-preferred