Module: ThecoreSettings::Processing
- Included in:
- Setting
- Defined in:
- lib/thecore_settings/processing.rb
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #html_kind? ⇒ Boolean (also: #html_type?)
- #preprocessed_kind? ⇒ Boolean
- #text_kind? ⇒ Boolean (also: #text_type?)
- #to_s ⇒ Object
- #upload_kind? ⇒ Boolean (also: #upload_type?)
- #value ⇒ Object
Instance Method Details
#blank? ⇒ Boolean
50 51 52 53 54 55 56 57 58 |
# File 'lib/thecore_settings/processing.rb', line 50 def blank? if file_kind? file.url.nil? elsif raw.blank? || disabled? true else false end end |
#html_kind? ⇒ Boolean Also known as: html_type?
20 21 22 |
# File 'lib/thecore_settings/processing.rb', line 20 def html_kind? ['html', 'code', 'sanitize', 'sanitize_code', 'strip_tags', 'simple_format', 'simple_format_raw', 'sanitized'].include? kind end |
#preprocessed_kind? ⇒ Boolean
24 25 26 |
# File 'lib/thecore_settings/processing.rb', line 24 def preprocessed_kind? ['sanitize', 'sanitize_code', 'strip_tags', 'simple_format', 'simple_format_raw', 'sanitized'].include? kind end |
#text_kind? ⇒ Boolean Also known as: text_type?
12 13 14 |
# File 'lib/thecore_settings/processing.rb', line 12 def text_kind? (ThecoreSettings.kinds - ['phone', 'phones', 'integer', 'float', 'yaml', 'json', 'boolean']).include? kind end |
#to_s ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/thecore_settings/processing.rb', line 60 def to_s if yaml_kind? || json_kind? || phone_kind? || integer_kind? || float_kind? raw else value end end |
#upload_kind? ⇒ Boolean Also known as: upload_type?
16 17 18 |
# File 'lib/thecore_settings/processing.rb', line 16 def upload_kind? ['file', 'image'].include? kind end |
#value ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/thecore_settings/processing.rb', line 32 def value if upload_kind? unless defined?(Shrine) if file? file.url else nil end else file.url if file.present? end elsif raw.blank? || disabled? default_value else processed_value end end |