Module: Ivar::Checked
- Defined in:
- lib/ivar/checked.rb,
lib/ivar/checked/class_methods.rb,
lib/ivar/checked/instance_methods.rb
Overview
Provides automatic validation for instance variables. When included in a class, this module:
-
Automatically calls check_ivars after initialization
-
Extends the class with CheckPolicy for policy configuration
-
Extends the class with Macros for ivar declarations
-
Sets a default check policy of :warn
-
Handles proper inheritance of these behaviors in subclasses
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
When this module is included in a class, it extends the class with ClassMethods and includes the Validation module.
Class Method Details
.included(base) ⇒ Object
When this module is included in a class, it extends the class with ClassMethods and includes the Validation module
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ivar/checked.rb', line 21 def self.included(base) base.include(Validation) base.extend(ClassMethods) base.extend(CheckPolicy) base.extend(Macros) base.prepend(InstanceMethods) # Set default policy for Checked to :warn # This can be overridden by calling ivar_check_policy in the class base.ivar_check_policy(Ivar.check_policy) end |