Module: Virtus::TypeLookup
- Included in:
- Attribute
- Defined in:
- lib/virtus/support/type_lookup.rb
Overview
A module that adds type lookup to a class
Constant Summary collapse
- TYPE_FORMAT =
/\A[A-Z]\w*\z/.freeze
Class Method Summary collapse
-
.extended(model) ⇒ undefined
private
Set cache ivar on the model.
Instance Method Summary collapse
-
#determine_type(class_or_name) ⇒ Class?
Returns a descendant based on a name or class.
-
#primitive ⇒ Class
private
Return the default primitive supported.
Class Method Details
.extended(model) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set cache ivar on the model
15 16 17 |
# File 'lib/virtus/support/type_lookup.rb', line 15 def self.extended(model) model.instance_variable_set('@type_lookup_cache', {}) end |
Instance Method Details
#determine_type(class_or_name) ⇒ Class?
Returns a descendant based on a name or class
34 35 36 |
# File 'lib/virtus/support/type_lookup.rb', line 34 def determine_type(class_or_name) @type_lookup_cache[class_or_name] ||= determine_type_and_cache(class_or_name) end |
#primitive ⇒ Class
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the default primitive supported
43 44 45 |
# File 'lib/virtus/support/type_lookup.rb', line 43 def primitive raise NotImplementedError, "#{self}.primitive must be implemented" end |