trabajo-afectivo/lib/core_ext/class.rb

18 lines
410 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class Class
def to_app_model_url
@to_app_model_url ||= begin
to_s.gsub(%r{::}, '_')
.gsub(%r{([A-Z]+)([A-Z][a-z])}, '\1_\2')
.gsub(%r{([a-z\d])([A-Z])}, '\1_\2')
.tr('-', '_')
.downcase
end
end
def to_app_model
@to_app_model ||= to_s.gsub(%r{::}, '').to_sym
end
end