Class: Labimotion::Utils
- Inherits:
-
Object
- Object
- Labimotion::Utils
- Defined in:
- lib/labimotion/utils/utils.rb
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
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/labimotion/utils/utils.rb', line 29 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
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/labimotion/utils/utils.rb', line 41 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
53 54 55 |
# File 'lib/labimotion/utils/utils.rb', line 53 def self.element_name_dc(name) Labimotion::Utils.element_name(name)&.downcase end |
.elname_by_collection(name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/labimotion/utils/utils.rb', line 17 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
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/labimotion/utils/utils.rb', line 5 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 |