Class: Coursemology::Polyglot::Language
- Inherits:
-
Object
- Object
- Coursemology::Polyglot::Language
- Defined in:
- lib/coursemology/polyglot/extensions/language.rb
Class Method Summary collapse
-
.find_by(type:) ⇒ nil, Class
Finds the language class with the specified name.
-
.find_by!(type:) ⇒ Class
Finds the language class with the specified name.
Class Method Details
.find_by(type:) ⇒ nil, Class
Finds the language class with the specified name.
8 9 10 11 |
# File 'lib/coursemology/polyglot/extensions/language.rb', line 8 def self.find_by(type:) class_ = concrete_languages.find { |language| language.name == type } class_.new if class_ end |
.find_by!(type:) ⇒ Class
Finds the language class with the specified name.
18 19 20 21 22 23 |
# File 'lib/coursemology/polyglot/extensions/language.rb', line 18 def self.find_by!(type:) language = find_by(type: type) fail ArgumentError, "Cannot find the language #{type}" unless language language end |