Module: Virtus::ModuleExtensions

Includes:
ConstMissingExtensions
Defined in:
lib/virtus/module_extensions.rb

Overview

Virtus module that can define attributes for later inclusion

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ConstMissingExtensions

#const_missing

Class Method Details

.extended(mod) ⇒ 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.



10
11
12
13
# File 'lib/virtus/module_extensions.rb', line 10

def self.extended(mod)
  super
  setup(mod)
end

.setup(mod, inclusions = [Model], attribute_definitions = []) ⇒ 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.



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

def self.setup(mod, inclusions = [Model], attribute_definitions = [])
  mod.instance_variable_set('@inclusions', inclusions)
  mod.instance_variable_set('@attribute_definitions', attribute_definitions)
end

Instance Method Details

#attribute(name, type = nil, options = {}) ⇒ self

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.

Define an attribute in the module

Returns:

  • (self)

See Also:

  • Extensions#attribute


28
29
30
31
# File 'lib/virtus/module_extensions.rb', line 28

def attribute(name, type = nil, options = {})
  @attribute_definitions << [name, type, options]
  self
end