Class: Oaken::Loader::Type
- Inherits:
-
Struct
- Object
- Struct
- Oaken::Loader::Type
- Defined in:
- lib/oaken/loader/type.rb
Instance Attribute Summary collapse
-
#gsub ⇒ Object
Returns the value of attribute gsub.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#gsub ⇒ Object
Returns the value of attribute gsub
3 4 5 |
# File 'lib/oaken/loader/type.rb', line 3 def gsub @gsub end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/oaken/loader/type.rb', line 3 def name @name end |
Class Method Details
.for(name) ⇒ Object
5 |
# File 'lib/oaken/loader/type.rb', line 5 def self.for(name) = new(name, name.classify.gsub(/(?<=[a-z])(?=[A-Z])/)) |
.locate(name) ⇒ Object
4 |
# File 'lib/oaken/loader/type.rb', line 4 def self.locate(name) = self.for(name.to_s).locate |
Instance Method Details
#locate ⇒ Object
7 8 9 |
# File 'lib/oaken/loader/type.rb', line 7 def locate possible_consts.filter_map(&:safe_constantize).first end |
#possible_consts ⇒ Object
11 12 13 14 15 |
# File 'lib/oaken/loader/type.rb', line 11 def possible_consts separator_matrixes.fetch(gsub.count).map { |seps| gsub.with_index { seps[_2] } } rescue KeyError raise ArgumentError, "can't resolve #{name} to an object, please call register manually" end |