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)


46
47
48
49
50
51
52
53
54
# File 'lib/rails_admin_settings/processing.rb', line 46

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', 'sanitize', 'sanitize_code', 'strip_tags', 'simple_format', 'simple_format_raw', 'sanitized'].include? kind
end

#preprocessed_kind?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/rails_admin_settings/processing.rb', line 24

def preprocessed_kind?
  ['sanitize', 'sanitize_code', 'strip_tags', 'simple_format', 'simple_format_raw', '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', 'float', 'yaml', 'json', 'boolean']).include? kind
end

#to_sObject



56
57
58
59
60
61
62
63
# File 'lib/rails_admin_settings/processing.rb', line 56

def to_s
  if yaml_kind? || json_kind? || phone_kind? || integer_kind? || float_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



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rails_admin_settings/processing.rb', line 32

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