Method: Protod::RubyIdent.build_from
- Defined in:
- lib/protod/ruby_ident.rb
.build_from(string) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/protod/ruby_ident.rb', line 11 def build_from(string) return if string.blank? string = string.gsub('__', '::') const_name, method_name, singleton = case when string.include?('.') [*string.split('.'), true] when string.include?('#') [*string.split('#'), false] else [string, nil, false] end return unless const_name.safe_constantize new(const_name: const_name, method_name: method_name, singleton: singleton) end |