Module: Taro::Types::Shared::DerivedTypes
- Defined in:
- lib/taro/types/shared/derived_types.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#define_derived_type(name, derivable_type) ⇒ Object
Adds ‘name` as a method to all type classes and adds :`name`_of as a supported key to the Coercion module.
- #derived_types ⇒ Object
Class Method Details
.map ⇒ Object
15 16 17 |
# File 'lib/taro/types/shared/derived_types.rb', line 15 def self.map @map ||= {} end |
Instance Method Details
#define_derived_type(name, derivable_type) ⇒ Object
Adds ‘name` as a method to all type classes and adds :`name`_of as a supported key to the Coercion module. When `name` is called on a type class T, it returns a new subclass S inheriting from `type` and passes T to S::derive_from.
6 7 8 9 |
# File 'lib/taro/types/shared/derived_types.rb', line 6 def define_derived_type(name, derivable_type) add_coercion_key(name) add_derivation_method(name, derivable_type) end |
#derived_types ⇒ Object
11 12 13 |
# File 'lib/taro/types/shared/derived_types.rb', line 11 def derived_types Taro::Types::Shared::DerivedTypes.map[self] ||= {} end |