Module: Lotus::Validations::AttributeDefiner Private
- Defined in:
- lib/lotus/validations/attribute_definer.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Define attributes and their validations together
Defined Under Namespace
Modules: ClassMethods, EntityAttributeDefiner
Constant Summary collapse
- LOTUS_ENTITY_CLASS_NAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'Lotus::Entity'.freeze
- LOTUS_ENTITY_ID =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'id'.freeze
Class Method Summary collapse
-
.included(base) ⇒ Object
private
Override Ruby’s hook for modules.
-
.lotus_entity?(base) ⇒ Boolean
private
Decide if enable the support for ‘Lotus::Entity`.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Object
private
Create a new instance with the given attributes.
Class Method Details
.included(base) ⇒ 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.
Override Ruby’s hook for modules.
28 29 30 31 |
# File 'lib/lotus/validations/attribute_definer.rb', line 28 def self.included(base) base.extend ClassMethods base.extend EntityAttributeDefiner if lotus_entity?(base) end |
.lotus_entity?(base) ⇒ Boolean
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.
Decide if enable the support for ‘Lotus::Entity`.
39 40 41 42 43 |
# File 'lib/lotus/validations/attribute_definer.rb', line 39 def self.lotus_entity?(base) base.included_modules.any? do |m| m.to_s == LOTUS_ENTITY_CLASS_NAME end end |
Instance Method Details
#initialize(attributes = {}) ⇒ 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.
Create a new instance with the given attributes
510 511 512 513 514 515 516 |
# File 'lib/lotus/validations/attribute_definer.rb', line 510 def initialize(attributes = {}) @attributes ||= Utils::Attributes.new attributes.to_h.each do |key, value| public_send("#{ key }=", value) if assign_attribute?(key) end end |