Module: RailsAdminSettings::Processing

Included in:
Setting
Defined in:
lib/rails_admin_settings/processing.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
48
49
# File 'lib/rails_admin_settings/processing.rb', line 41

def blank?
  if file_kind?
    file.url.nil?
  elsif raw.blank? || disabled?
    true
  else
    false
  end
end

#html_kind?Boolean Also known as: html_type?

Returns:

  • (Boolean)


20
21
22
# File 'lib/rails_admin_settings/processing.rb', line 20

def html_kind?
  ['html', 'code', 'sanitized'].include? kind
end

#text_kind?Boolean Also known as: text_type?

Returns:

  • (Boolean)


12
13
14
# File 'lib/rails_admin_settings/processing.rb', line 12

def text_kind?
  (RailsAdminSettings.kinds - ['phone', 'phones', 'integer', 'yaml', 'boolean']).include? kind
end

#to_sObject



51
52
53
54
55
56
57
# File 'lib/rails_admin_settings/processing.rb', line 51

def to_s
  if yaml_kind? || phone_kind? || integer_kind?
    raw
  else
    value
  end
end

#upload_kind?Boolean Also known as: upload_type?

Returns:

  • (Boolean)


16
17
18
# File 'lib/rails_admin_settings/processing.rb', line 16

def upload_kind?
  ['file', 'image'].include? kind
end

#valueObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rails_admin_settings/processing.rb', line 27

def value
  if upload_kind?
    if file_kind?
      file.url
    else
      nil
    end
  elsif raw.blank? || disabled?
    default_value
  else
    processed_value
  end
end