Module: AngryMob::Target::Tracking
- Included in:
- AngryMob::Target
- Defined in:
- lib/angry_mob/target/tracking.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
-
.register_klass_file(klass) ⇒ Object
Whenever a class inherits from AngryMob::Target, we should track the class and the file on AngryMob::Target::Tracking.
-
.subclass_files ⇒ Object
Returns the files where the subclasses are kept.
-
.subclasses ⇒ Object
Returns the classes that inherit from AngryMob::Target.
Class Method Details
.included(base) ⇒ Object
:nodoc:
5 6 7 |
# File 'lib/angry_mob/target/tracking.rb', line 5 def included(base) #:nodoc: base.send :extend, ClassMethods end |
.register_klass_file(klass) ⇒ Object
Whenever a class inherits from AngryMob::Target, we should track the class and the file on AngryMob::Target::Tracking. This is the method responsable for it.
22 23 24 25 26 27 28 29 30 |
# File 'lib/angry_mob/target/tracking.rb', line 22 def register_klass_file(klass) #:nodoc: file = caller[1].match(/(.*):\d+/)[1] nickname = klass.nickname.to_s AngryMob::Target::Tracking.subclasses[nickname] = klass unless AngryMob::Target::Tracking.subclasses.key?(nickname) file_subclasses = AngryMob::Target::Tracking.subclass_files[File.(file)] file_subclasses << klass unless file_subclasses.include?(klass) end |
.subclass_files ⇒ Object
Returns the files where the subclasses are kept.
15 16 17 |
# File 'lib/angry_mob/target/tracking.rb', line 15 def subclass_files @subclass_files ||= Hash.new{ |h,k| h[k] = [] } end |
.subclasses ⇒ Object
Returns the classes that inherit from AngryMob::Target
10 11 12 |
# File 'lib/angry_mob/target/tracking.rb', line 10 def subclasses @subclasses ||= {} end |