Class: ThecoreSettings::Setting

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Mongoid, Processing, RailsAdminConfig, RequireHelpers, Uploads, Validation
Defined in:
app/models/thecore_settings/setting.rb,
app/models/thecore_settings/setting.rb

Instance Method Summary collapse

Methods included from RailsAdminConfig

included

Methods included from Validation

add_color_validator, add_email_validator, add_file_validator, add_geo_validator, add_json_validator, add_phone_validator, add_url_validator, add_validators, add_yaml_validator, included

Methods included from Uploads

included, paperclip_options

Methods included from Processing

#blank?, #html_kind?, #preprocessed_kind?, #text_kind?, #to_s, #upload_kind?, #value

Instance Method Details

#as_yaml(options = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'app/models/thecore_settings/setting.rb', line 50

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

Returns:

  • (Boolean)


26
27
28
# File 'app/models/thecore_settings/setting.rb', line 26

def disabled?
  !enabled
end

#enabled?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/thecore_settings/setting.rb', line 30

def enabled?
  enabled
end

#nameObject



34
35
36
# File 'app/models/thecore_settings/setting.rb', line 34

def name
  label.blank? ? key : label
end

#to_pathObject



42
43
44
45
46
47
48
# File 'app/models/thecore_settings/setting.rb', line 42

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

#typeObject



38
39
40
# File 'app/models/thecore_settings/setting.rb', line 38

def type
  kind
end