Class: Administrate::Field::Hyperlink
- Inherits:
-
String
- Object
- String
- Administrate::Field::Hyperlink
show all
- Includes:
- HyperlinkVersion
- Defined in:
- lib/administrate/field/hyperlink.rb
Defined Under Namespace
Classes: Engine
Constant Summary
Administrate::Field::HyperlinkVersion::VERSION
Instance Method Summary
collapse
Instance Method Details
#href ⇒ Object
22
23
24
25
26
27
|
# File 'lib/administrate/field/hyperlink.rb', line 22
def href
return options.fetch(:fallback_href) { nil } unless data.present?
return data if data.include?('://') || data.start_with?('//')
"#{options.fetch(:scheme) { 'https://' }}#{data}"
end
|
#present? ⇒ Boolean
12
13
14
|
# File 'lib/administrate/field/hyperlink.rb', line 12
def present?
(data.presence || options.fetch(:fallback_href) { nil }).present?
end
|
#to_s ⇒ Object
16
17
18
19
20
|
# File 'lib/administrate/field/hyperlink.rb', line 16
def to_s
options.fetch(:label) do
data.presence || options.fetch(:fallback_href) { nil }
end
end
|