Module: SleepingKingStudios::Tools::Toolbox::HeritableData
- Defined in:
- lib/sleeping_king_studios/tools/toolbox/heritable_data.rb
Overview
Mixin to allow defining subclasses of Data classes.
Defined Under Namespace
Modules: ClassMethods Classes: HeritableMethods
Class Method Summary collapse
-
.define(*symbols, parent_class: nil) { ... } ⇒ Object
Defines a new heritable Data class.
Instance Method Summary collapse
-
#is_a?(type) ⇒ true
(also: #kind_of?)
Checks if the object class inherits from type.
Class Method Details
.define(*symbols, parent_class: nil) { ... } ⇒ Object
Defines a new heritable Data class.
154 155 156 157 158 159 160 |
# File 'lib/sleeping_king_studios/tools/toolbox/heritable_data.rb', line 154 def define(*symbols, parent_class: nil, &) Data.define(*parent_class&.members, *symbols).tap do |data_class| data_class.include(HeritableData) define_mixin_for(data_class, parent_class, &) end end |
Instance Method Details
#is_a?(type) ⇒ true Also known as: kind_of?
Checks if the object class inherits from type.
186 187 188 |
# File 'lib/sleeping_king_studios/tools/toolbox/heritable_data.rb', line 186 def is_a?(type) super || self.class < type || false end |