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
strict[RW]
Access the strict setting for this instance
Public Class Methods
build(options = {}, &block)
click to toggle source
Build new configuration instance using the passed block
@example
Configuration.build do |config| config.coerce = false end
@return [Configuration]
@api public
# File lib/virtus/configuration.rb, line 31 def self.build(options = {}, &block) config = new.call(&block) options.each { |key, value| config.public_send("#{key}=", value) } config end
new()
click to toggle source
Initialized a configuration instance
@return [undefined]
@api private
# File lib/virtus/configuration.rb, line 42 def initialize @finalize = true @coerce = true @strict = false @constructor = true @mass_assignment = true @coercer = Coercible::Coercer.new end
Public Instance Methods
call(&block)
click to toggle source
Provide access to the attributes and methods via the passed block
@example
configuration.call do |config| config.coerce = false end
@return [self]
@api private
# File lib/virtus/configuration.rb, line 61 def call(&block) block.call(self) if block_given? self end
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 77 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 83 def to_h { :coerce => coerce, :finalize => finalize, :strict => strict, :configured_coercer => coercer }.freeze end