Class: RailsAdminSettings::Setting

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
RailsAdminComments::Commentable, RailsAdminComments::ModelCommentable, Mongoid, Processing, RailsAdminConfig, RequireHelpers, Uploads, Validation
Defined in:
app/models/rails_admin_settings/setting.rb,
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_kind?, #text_kind?, #to_s, #upload_kind?, #value

Instance Method Details

#as_yaml(options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'app/models/rails_admin_settings/setting.rb', line 56

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



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

def disabled?
  !enabled
end

#enabled?Boolean



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

def enabled?
  enabled
end

#nameObject



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

def name
  label.blank? ? key : label
end

#to_pathObject



48
49
50
51
52
53
54
# File 'app/models/rails_admin_settings/setting.rb', line 48

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

#typeObject



44
45
46
# File 'app/models/rails_admin_settings/setting.rb', line 44

def type
  kind
end