Class: TinyAdmin::Support
- Inherits:
-
Object
- Object
- TinyAdmin::Support
- Defined in:
- lib/tiny_admin/support.rb
Class Method Summary collapse
- .call(value, options: []) ⇒ Object
- .downcase(value, options: []) ⇒ Object
- .format(value, options: []) ⇒ Object
- .label_for(value, options: []) ⇒ Object
- .round(value, options: []) ⇒ Object
- .strftime(value, options: []) ⇒ Object
- .to_date(value, options: []) ⇒ Object
- .upcase(value, options: []) ⇒ Object
Class Method Details
.call(value, options: []) ⇒ Object
6 7 8 |
# File 'lib/tiny_admin/support.rb', line 6 def call(value, options: []) .inject(value) { |result, | result&.send() } if value && &.any? end |
.downcase(value, options: []) ⇒ Object
10 11 12 |
# File 'lib/tiny_admin/support.rb', line 10 def downcase(value, options: []) value&.downcase end |
.format(value, options: []) ⇒ Object
14 15 16 |
# File 'lib/tiny_admin/support.rb', line 14 def format(value, options: []) Kernel.format(.first, value) if value && &.any? end |
.label_for(value, options: []) ⇒ Object
18 19 20 |
# File 'lib/tiny_admin/support.rb', line 18 def label_for(value, options: []) value end |
.round(value, options: []) ⇒ Object
22 23 24 |
# File 'lib/tiny_admin/support.rb', line 22 def round(value, options: []) value&.round(&.first&.to_i || 2) end |
.strftime(value, options: []) ⇒ Object
26 27 28 |
# File 'lib/tiny_admin/support.rb', line 26 def strftime(value, options: []) value&.strftime(&.first || '%Y-%m-%d %H:%M') end |
.to_date(value, options: []) ⇒ Object
30 31 32 |
# File 'lib/tiny_admin/support.rb', line 30 def to_date(value, options: []) value.to_date.to_s if value end |
.upcase(value, options: []) ⇒ Object
34 35 36 |
# File 'lib/tiny_admin/support.rb', line 34 def upcase(value, options: []) value&.upcase end |