Class: Blacklight::FieldRetriever
- Inherits:
-
Object
- Object
- Blacklight::FieldRetriever
- Defined in:
- app/services/blacklight/field_retriever.rb
Instance Attribute Summary collapse
- #document ⇒ Blacklight::Document readonly
- #field_config ⇒ Blacklight::Configuration::Field readonly
- #view_context ⇒ ActionView::Base readonly
Instance Method Summary collapse
- #fetch ⇒ Array
-
#initialize(document, field_config, view_context = nil) ⇒ FieldRetriever
constructor
A new instance of FieldRetriever.
Constructor Details
#initialize(document, field_config, view_context = nil) ⇒ FieldRetriever
Returns a new instance of FieldRetriever.
8 9 10 11 12 |
# File 'app/services/blacklight/field_retriever.rb', line 8 def initialize(document, field_config, view_context = nil) @document = document @field_config = field_config @view_context = view_context end |
Instance Attribute Details
#document ⇒ Blacklight::Document (readonly)
15 16 17 |
# File 'app/services/blacklight/field_retriever.rb', line 15 def document @document end |
#field_config ⇒ Blacklight::Configuration::Field (readonly)
17 18 19 |
# File 'app/services/blacklight/field_retriever.rb', line 17 def field_config @field_config end |
#view_context ⇒ ActionView::Base (readonly)
19 20 21 |
# File 'app/services/blacklight/field_retriever.rb', line 19 def view_context @view_context end |
Instance Method Details
#fetch ⇒ Array
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/blacklight/field_retriever.rb', line 24 def fetch if field_config.highlight value = retrieve_highlight end if value.blank? value = if field_config.accessor retieve_using_accessor elsif field_config.values retrieve_values else retrieve_simple end end Array.wrap(value) end |