Module: RailsAdminSettings::Processing

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

Instance Method Summary collapse

Instance Method Details

#array_kind?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rails_admin_settings/processing.rb', line 27

def array_kind?
  ['array'].include? kind
end

#blank?Boolean

Returns:

  • (Boolean)


52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rails_admin_settings/processing.rb', line 52

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

#hash_kind?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/rails_admin_settings/processing.rb', line 30

def hash_kind?
  ['hash'].include? kind
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



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/rails_admin_settings/processing.rb', line 66

def to_s
  if yaml_kind? || phone_kind? || integer_kind?
    raw
  elsif array_kind?
    raw_array.join(", ")
  elsif hash_kind?
    raw_hash.to_json
  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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rails_admin_settings/processing.rb', line 34

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