Class: Spotlight::SolrDocument::SpotlightImages::Versions
- Inherits:
-
Object
- Object
- Spotlight::SolrDocument::SpotlightImages::Versions
- Includes:
- ImageDerivatives
- Defined in:
- app/models/concerns/spotlight/solr_document/spotlight_images.rb
Overview
Spotlight image derivivative class
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#versions ⇒ Object
readonly
Returns the value of attribute versions.
Instance Method Summary collapse
- #image_versions(*args) ⇒ Object
-
#initialize(document) ⇒ Versions
constructor
A new instance of Versions.
Methods included from ImageDerivatives
#apply_spotlight_image_derivative_versions
Constructor Details
#initialize(document) ⇒ Versions
Returns a new instance of Versions.
24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/concerns/spotlight/solr_document/spotlight_images.rb', line 24 def initialize(document) @document = document @versions = spotlight_image_derivatives.map do |derivative| version = version_name(derivative) self.class.send(:define_method, version) do Array.wrap(document.fetch(derivative[:field], [])) end version end end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
22 23 24 |
# File 'app/models/concerns/spotlight/solr_document/spotlight_images.rb', line 22 def document @document end |
#versions ⇒ Object (readonly)
Returns the value of attribute versions.
22 23 24 |
# File 'app/models/concerns/spotlight/solr_document/spotlight_images.rb', line 22 def versions @versions end |
Instance Method Details
#image_versions(*args) ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/models/concerns/spotlight/solr_document/spotlight_images.rb', line 35 def image_versions(*args) send(args.first).each_with_index.map do |_img, i| args.each_with_object({}) do |version, hash| hash[version] = send(version)[i] end end end |