Module: Aws::Templates::Utils::Inheritable::ClassMethods
- Included in:
- Aws::Templates::Utils::Inheritable
- Defined in:
- lib/aws/templates/utils/inheritable.rb
Overview
Core class-level mixins
Contains core logic of the inheritance feature. This module is used as extention in every including module/class to expose appropriate module-level primitives for handling inheritance of class-scope methods.
Defined Under Namespace
Modules: ClassScope
Instance Method Summary collapse
- #_class_scope_defined? ⇒ Boolean
- #_define_class_scope ⇒ Object
- #class_scope(&blk) ⇒ Object
-
#included(base) ⇒ Object
To add class methods also while including the module.
- #instance_scope(&blk) ⇒ Object
Instance Method Details
#_class_scope_defined? ⇒ Boolean
43 44 45 |
# File 'lib/aws/templates/utils/inheritable.rb', line 43 def _class_scope_defined? @class_scope_defined || false end |
#_define_class_scope ⇒ Object
47 48 49 50 |
# File 'lib/aws/templates/utils/inheritable.rb', line 47 def _define_class_scope const_set(:ClassScope, ClassScope.dup) @class_scope_defined = true end |
#class_scope(&blk) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/aws/templates/utils/inheritable.rb', line 36 def class_scope(&blk) raise ScriptError.new('class_scope should have a block') if blk.nil? _define_class_scope unless _class_scope_defined? ClassScope.module_eval(&blk) extend ClassScope end |
#included(base) ⇒ Object
To add class methods also while including the module
26 27 28 29 30 |
# File 'lib/aws/templates/utils/inheritable.rb', line 26 def included(base) super(base) base.extend(ClassMethods) base.extend(ClassScope) end |
#instance_scope(&blk) ⇒ Object
32 33 34 |
# File 'lib/aws/templates/utils/inheritable.rb', line 32 def instance_scope(&blk) module_eval(&blk) end |