Method: Hanami::Utils::Kernel.Symbol
- Defined in:
- lib/hanami/utils/kernel.rb
permalink .Symbol(arg) ⇒ Symbol
Coerces the argument to be a Symbol.
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 |
# File 'lib/hanami/utils/kernel.rb', line 1015 def self.Symbol(arg) case arg when "" then raise TypeError.new "can't convert #{inspect_type_error(arg)}into Symbol" when ->(a) { a.respond_to?(:to_sym) } then arg.to_sym else # rubocop:disable Lint/DuplicateBranch raise TypeError.new "can't convert #{inspect_type_error(arg)}into Symbol" end rescue NoMethodError raise TypeError.new "can't convert #{inspect_type_error(arg)}into Symbol" end |