Module: Card::Set::Registrar
- Included in:
- Card::Set
- Defined in:
- lib/card/set/registrar.rb
Overview
the set loading process has two main phases:
1. Definition: interpret each set file, creating/defining set and
set_format modules
2. Organization: have base classes include modules associated with the
'all' set, and clean up the other modules
Instance Method Summary collapse
-
#extended(mod) ⇒ Object
each set file calls ‘extend Card::Set` when loaded.
- #finalize_load ⇒ Object
-
#process_base_modules ⇒ Object
‘base modules’ are modules that are always included on the Card or Format class ‘nonbase modules’ are included dynamically on singleton_classes.
-
#register_set(set_module) ⇒ Object
make the set available for use.
Instance Method Details
#extended(mod) ⇒ Object
each set file calls ‘extend Card::Set` when loaded
16 17 18 |
# File 'lib/card/set/registrar.rb', line 16 def extended mod register_set mod end |
#finalize_load ⇒ Object
51 52 53 54 55 |
# File 'lib/card/set/registrar.rb', line 51 def finalize_load # basket.freeze # basket.each_value(&:freeze) clean_empty_modules end |
#process_base_modules ⇒ Object
‘base modules’ are modules that are always included on the Card or Format class ‘nonbase modules’ are included dynamically on singleton_classes
42 43 44 45 46 47 48 49 |
# File 'lib/card/set/registrar.rb', line 42 def process_base_modules base_modules = modules[:base] return unless base_modules.present? Card.add_set_modules base_modules process_base_format_modules modules[:base_format] base_modules.clear end |
#register_set(set_module) ⇒ Object
make the set available for use
21 22 23 24 25 26 27 28 29 |
# File 'lib/card/set/registrar.rb', line 21 def register_set set_module if set_module.all_set? # automatically included in Card class modules[:base] << set_module else set_type = set_module.abstract_set? ? :abstract : :nonbase register_set_of_type set_module, set_type end end |