Class: RailsAdminSettings::Setting

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Audit::Trackable, Mongoid::Document, Mongoid::Timestamps::Short, Processing, RailsAdminConfig, RequireHelpers, Uploads, Validation
Defined in:
app/models/rails_admin_settings/setting.rb

Instance Method Summary collapse

Methods included from RailsAdminConfig

included

Methods included from Validation

included

Methods included from Uploads

included

Methods included from Processing

#blank?, #html_type?, #text_type?, #to_s, #upload_type?, #value

Instance Method Details

#as_yaml(options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'app/models/rails_admin_settings/setting.rb', line 53

def as_yaml(options = {})
  v = {type: type, enabled: enabled, label: label}
  if upload_type?
    v[:value] = to_path
  else
    v[:value] = raw
  end
  v.stringify_keys!
  v
end

#disabled?Boolean



33
34
35
# File 'app/models/rails_admin_settings/setting.rb', line 33

def disabled?
  !enabled
end

#enabled?Boolean



37
38
39
# File 'app/models/rails_admin_settings/setting.rb', line 37

def enabled?
  enabled
end

#nameObject



41
42
43
# File 'app/models/rails_admin_settings/setting.rb', line 41

def name
  label.blank? ? key : label
end

#to_pathObject



45
46
47
48
49
50
51
# File 'app/models/rails_admin_settings/setting.rb', line 45

def to_path
  if value.nil?
    nil
  else
    URI.parse(value).path
  end
end