Class: TinyAdmin::Support

Inherits:
Object
  • Object
show all
Defined in:
lib/tiny_admin/support.rb

Class Method Summary collapse

Class Method Details

.call(value, options: []) ⇒ Object



6
7
8
# File 'lib/tiny_admin/support.rb', line 6

def call(value, options: [])
  options.inject(value) { |result, message| result&.send(message) } if value && options&.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(options.first, value) if value && options&.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(options&.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(options&.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