Class: Virtus::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/virtus/builder.rb,
lib/virtus/builder/hook_context.rb

Overview

Class to build a Virtus module with it’s own config

This allows for individual Virtus modules to be included in classes and not impacted by the global Virtus config, which is implemented using Virtus::config.

Direct Known Subclasses

ModelBuilder, ModuleBuilder, ValueObjectBuilder

Defined Under Namespace

Classes: HookContext

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf, mod = Module.new) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes a new Builder

Parameters:



44
45
46
47
48
# File 'lib/virtus/builder.rb', line 44

def initialize(conf, mod = Module.new)
  @config, @mod = conf, mod
  add_included_hook
  add_extended_hook
end

Instance Attribute Details

#configconfig (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return config

Returns:



24
25
26
# File 'lib/virtus/builder.rb', line 24

def config
  @config
end

#modModule (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return module

Returns:

  • (Module)


17
18
19
# File 'lib/virtus/builder.rb', line 17

def mod
  @mod
end

Class Method Details

.call(options, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/virtus/builder.rb', line 27

def self.call(options, &block)
  new(Configuration.build(options, &block)).mod
end

.pendingObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
# File 'lib/virtus/builder.rb', line 32

def self.pending
  @pending ||= []
end

Instance Method Details

#extensionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
# File 'lib/virtus/builder.rb', line 51

def extensions
  [Model::Core]
end

#optionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



56
57
58
# File 'lib/virtus/builder.rb', line 56

def options
  config.to_h
end