Class: ThecoreSettings::Setting
Instance Method Summary
collapse
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
26
27
28
|
# File 'app/models/thecore_settings/setting.rb', line 26
def disabled?
!enabled
end
|
#enabled? ⇒ Boolean
30
31
32
|
# File 'app/models/thecore_settings/setting.rb', line 30
def enabled?
enabled
end
|
#name ⇒ Object
34
35
36
|
# File 'app/models/thecore_settings/setting.rb', line 34
def name
label.blank? ? key : label
end
|
#to_path ⇒ Object
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
|
#type ⇒ Object
38
39
40
|
# File 'app/models/thecore_settings/setting.rb', line 38
def type
kind
end
|