Class: Administrate::Field::Shrine
- Inherits:
-
Base
- Object
- Base
- Administrate::Field::Shrine
- Defined in:
- lib/administrate/field/shrine.rb
Defined Under Namespace
Classes: Engine
Instance Method Summary collapse
- #cached_value ⇒ Object
- #regular_url ⇒ Object
-
#url ⇒ Object
we should first try the regular data.url because if the versions are generated in the background by a worker they won’t be available immediately after submitting the form however, once data.url is available data.url won’t work, so we’re covered in both cases.
- #url_only? ⇒ Boolean
- #version ⇒ Object
- #version_url ⇒ Object
Instance Method Details
#cached_value ⇒ Object
35 36 37 |
# File 'lib/administrate/field/shrine.rb', line 35 def cached_value resource.send("cached_#{attribute}_data") end |
#regular_url ⇒ Object
19 20 21 |
# File 'lib/administrate/field/shrine.rb', line 19 def regular_url data.try(:url) end |
#url ⇒ Object
we should first try the regular data.url because if the versions are generated in the background by a worker they won’t be available immediately after submitting the form however, once data.url is available data.url won’t work, so we’re covered in both cases
15 16 17 |
# File 'lib/administrate/field/shrine.rb', line 15 def url (regular_url || version_url).to_s end |
#url_only? ⇒ Boolean
27 28 29 |
# File 'lib/administrate/field/shrine.rb', line 27 def url_only? .fetch(:url_only, false) end |
#version ⇒ Object
31 32 33 |
# File 'lib/administrate/field/shrine.rb', line 31 def version .fetch(:version, nil) end |
#version_url ⇒ Object
23 24 25 |
# File 'lib/administrate/field/shrine.rb', line 23 def version_url data.try(:[], version).try(:url) end |