Class: Transformers::LazyAutoMapping
- Inherits:
-
Object
- Object
- Transformers::LazyAutoMapping
- Defined in:
- lib/transformers/models/auto/auto_factory.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #include?(key) ⇒ Boolean
-
#initialize(config_mapping, model_mapping) ⇒ LazyAutoMapping
constructor
A new instance of LazyAutoMapping.
Constructor Details
#initialize(config_mapping, model_mapping) ⇒ LazyAutoMapping
Returns a new instance of LazyAutoMapping.
90 91 92 93 94 95 |
# File 'lib/transformers/models/auto/auto_factory.rb', line 90 def initialize(config_mapping, model_mapping) @config_mapping = config_mapping @reverse_config_mapping = config_mapping.invert @model_mapping = model_mapping @modules = {} end |
Instance Method Details
#[](key) ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'lib/transformers/models/auto/auto_factory.rb', line 97 def [](key) model_type = @reverse_config_mapping[key] if @model_mapping[model_type] model_name = @model_mapping[model_type] return _load_attr_from_module(model_type, model_name) end raise KeyError, key end |
#include?(key) ⇒ Boolean
107 108 109 110 111 112 |
# File 'lib/transformers/models/auto/auto_factory.rb', line 107 def include?(key) self[key] true rescue KeyError false end |