class Virtus::Configuration
A Configuration instance
Attributes
coerce[RW]
Access the coerce setting for this instance
constructor[RW]
Access the constructor setting for this instance
finalize[RW]
Access the finalize setting for this instance
mass_assignment[RW]
Access the mass-assignment setting for this instance
required[RW]
Access the required setting for this instance
strict[RW]
Access the strict setting for this instance
Public Class Methods
new(options={}) { |self| ... }
click to toggle source
Initialized a configuration instance
@return [undefined]
@api private
# File lib/virtus/configuration.rb, line 29 def initialize(options={}) @finalize = options.fetch(:finalize, true) @coerce = options.fetch(:coerce, true) @strict = options.fetch(:strict, false) @required = options.fetch(:required, true) @constructor = options.fetch(:constructor, true) @mass_assignment = options.fetch(:mass_assignment, true) @coercer = Coercible::Coercer.new yield self if block_given? end
Public Instance Methods
coercer(&block)
click to toggle source
Access the coercer for this instance and optional configure a new coercer with the passed block
@example
configuration.coercer do |config| config.string.boolean_map = { true => '1', false => '0' } end
@return [Coercer]
@api private
# File lib/virtus/configuration.rb, line 52 def coercer(&block) @coercer = Coercible::Coercer.new(&block) if block_given? @coercer end
to_h()
click to toggle source
@api private
# File lib/virtus/configuration.rb, line 58 def to_h { :coerce => coerce, :finalize => finalize, :strict => strict, :required => required, :configured_coercer => coercer }.freeze end