Class: Labimotion::Utils
- Inherits:
-
Object
- Object
- Labimotion::Utils
- Defined in:
- lib/labimotion/utils/utils.rb
Overview
Generic Utils
Class Method Summary collapse
- .col_by_element(name) ⇒ Object
- .element_name(name) ⇒ Object
- .element_name_dc(name) ⇒ Object
- .elname_by_collection(name) ⇒ Object
- .klass_by_collection(name) ⇒ Object
Class Method Details
.col_by_element(name) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/labimotion/utils/utils.rb', line 30 def self.col_by_element(name) names = name.split('::') if names.size == 1 "collections_#{name.underscore.pluralize}" else "collections_#{names.last.underscore.pluralize}" end rescue StandardError => e Labimotion.log_exception(e) name..underscore.pluralize end |
.element_name(name) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/labimotion/utils/utils.rb', line 42 def self.element_name(name) names = name.split('::') if names.size == 1 name else names.last end rescue StandardError => e Labimotion.log_exception(e) name end |
.element_name_dc(name) ⇒ Object
54 55 56 |
# File 'lib/labimotion/utils/utils.rb', line 54 def self.element_name_dc(name) Labimotion::Utils.element_name(name)&.downcase end |
.elname_by_collection(name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/labimotion/utils/utils.rb', line 18 def self.elname_by_collection(name) names = name.split('::') if names.size == 1 name[11..].underscore else names.last[11..].underscore end rescue StandardError => e Labimotion.log_exception(e) name.constantize end |
.klass_by_collection(name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/labimotion/utils/utils.rb', line 6 def self.klass_by_collection(name) names = name.split('::') if names.size == 1 name[11..] else "#{names[0]}::#{names.last[11..]}" end rescue StandardError => e Labimotion.log_exception(e, current_user) name end |