class.rb 410 B

1234567891011121314151617
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Class
  3. def to_app_model_url
  4. @to_app_model_url ||= begin
  5. to_s.gsub(%r{::}, '_')
  6. .gsub(%r{([A-Z]+)([A-Z][a-z])}, '\1_\2')
  7. .gsub(%r{([a-z\d])([A-Z])}, '\1_\2')
  8. .tr('-', '_')
  9. .downcase
  10. end
  11. end
  12. def to_app_model
  13. @to_app_model ||= to_s.gsub(%r{::}, '').to_sym
  14. end
  15. end