Class: Administrate::Field::Shrine

Inherits:
Base
  • Object
show all
Defined in:
lib/administrate/field/shrine.rb

Defined Under Namespace

Classes: Engine

Instance Method Summary collapse

Instance Method Details

#cached_valueObject



35
36
37
# File 'lib/administrate/field/shrine.rb', line 35

def cached_value
  resource.send("cached_#{attribute}_data")
end

#regular_urlObject



19
20
21
# File 'lib/administrate/field/shrine.rb', line 19

def regular_url
  data.try(:url)
end

#urlObject

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

Returns:

  • (Boolean)


27
28
29
# File 'lib/administrate/field/shrine.rb', line 27

def url_only?
  options.fetch(:url_only, false)
end

#versionObject



31
32
33
# File 'lib/administrate/field/shrine.rb', line 31

def version
  options.fetch(:version, nil)
end

#version_urlObject



23
24
25
# File 'lib/administrate/field/shrine.rb', line 23

def version_url
  data.try(:[], version).try(:url)
end