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
- .extended(mod) ⇒ Object private
- .setup(mod, inclusions = [Model], attribute_definitions = []) ⇒ Object private
Instance Method Summary collapse
-
#attribute(name, type = nil, options = {}) ⇒ self
private
Define an attribute in the module.
Methods included from ConstMissingExtensions
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
28 29 30 31 |
# File 'lib/virtus/module_extensions.rb', line 28 def attribute(name, type = nil, = {}) @attribute_definitions << [name, type, ] self end |