Module: Typingpool::Utility::Castable::ClassMethods
- Defined in:
- lib/typingpool/utility/castable.rb
Instance Method Summary collapse
- #inherited(subklass) ⇒ Object
- #relative_klass(key) ⇒ Object
- #subklass(subklass_key) ⇒ Object
- #subklasses ⇒ Object
Instance Method Details
#inherited(subklass) ⇒ Object
42 43 44 |
# File 'lib/typingpool/utility/castable.rb', line 42 def inherited(subklass) subklasses[subklass.to_s.split("#{self.name}::").last.downcase.gsub(/::/, '_')] = subklass end |
#relative_klass(key) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/typingpool/utility/castable.rb', line 54 def relative_klass(key) if subklasses[key] subklasses[key] elsif self.superclass.respond_to? :relative_klass self.superclass.relative_klass(key) end end |
#subklass(subklass_key) ⇒ Object
50 51 52 |
# File 'lib/typingpool/utility/castable.rb', line 50 def subklass(subklass_key) subklasses[subklass_key] end |
#subklasses ⇒ Object
46 47 48 |
# File 'lib/typingpool/utility/castable.rb', line 46 def subklasses @subklasses ||= {} end |