Class: Blacklight::IndexPresenter
- Inherits:
-
Object
- Object
- Blacklight::IndexPresenter
- Extended by:
- Deprecation
- Defined in:
- app/presenters/blacklight/index_presenter.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#view_context ⇒ Object
readonly
Returns the value of attribute view_context.
Instance Method Summary collapse
-
#field_value(field_or_name, options = {}) ⇒ Object
Render the index field label for a document.
- #get_field_values(field_config, options = {}) ⇒ Object deprecated Deprecated.
-
#initialize(document, view_context, configuration = view_context.blacklight_config) ⇒ IndexPresenter
constructor
A new instance of IndexPresenter.
-
#label(field_or_string_or_proc, opts = {}) ⇒ Object
Render the document index heading.
- #render_document_index_label(*args) ⇒ Object deprecated Deprecated.
- #render_field_values(values, field_config = Configuration::NullField.new) ⇒ Object deprecated Deprecated.
- #render_index_field_value(*args) ⇒ Object deprecated Deprecated.
- #render_values(values, field_config = Configuration::NullField.new) ⇒ Object deprecated Deprecated.
Constructor Details
#initialize(document, view_context, configuration = view_context.blacklight_config) ⇒ IndexPresenter
Returns a new instance of IndexPresenter.
12 13 14 15 16 |
# File 'app/presenters/blacklight/index_presenter.rb', line 12 def initialize(document, view_context, configuration = view_context.blacklight_config) @document = document @view_context = view_context @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
7 8 9 |
# File 'app/presenters/blacklight/index_presenter.rb', line 7 def configuration @configuration end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
7 8 9 |
# File 'app/presenters/blacklight/index_presenter.rb', line 7 def document @document end |
#view_context ⇒ Object (readonly)
Returns the value of attribute view_context.
7 8 9 |
# File 'app/presenters/blacklight/index_presenter.rb', line 7 def view_context @view_context end |
Instance Method Details
#field_value(field_or_name, options = {}) ⇒ Object
Render the index field label for a document
Allow an extention point where information in the document may drive the value of the field
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/presenters/blacklight/index_presenter.rb', line 54 def field_value field_or_name, = {} field = case field_or_name when Blacklight::Configuration::Field field_or_name when String, Symbol Deprecation.warn(self, "You provided a #{field_or_name.class} value to IndexPresenter#field_value " \ "Provide a Blacklight::Configuration::Field instead. This behavior is deprecated in Blacklight 7") field_config(field_or_name) else Deprecation.warn(self, "You provided a #{field_or_name.class} value to IndexPresenter#field_value. " \ "This will be silently ignored and will be an error in Blacklight 7.") Configuration::NullField.new end field_values(field, ) end |
#get_field_values(field_config, options = {}) ⇒ Object
Deprecated.
78 79 80 |
# File 'app/presenters/blacklight/index_presenter.rb', line 78 def get_field_values(field_config, ={}) field_values(field_config, ) end |
#label(field_or_string_or_proc, opts = {}) ⇒ Object
Render the document index heading
TODO: the default field should be `document_show_link_field(doc)'
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/presenters/blacklight/index_presenter.rb', line 24 def label(field_or_string_or_proc, opts = {}) config = Configuration::NullField.new value = case field_or_string_or_proc when Symbol config = field_config(field_or_string_or_proc) document[field_or_string_or_proc] when Proc field_or_string_or_proc.call(document, opts) when String field_or_string_or_proc end value ||= document.id field_values(config, value: value) end |
#render_document_index_label(*args) ⇒ Object
Deprecated.
41 42 43 |
# File 'app/presenters/blacklight/index_presenter.rb', line 41 def render_document_index_label(*args) label(*args) end |
#render_field_values(values, field_config = Configuration::NullField.new) ⇒ Object
Deprecated.
84 85 86 |
# File 'app/presenters/blacklight/index_presenter.rb', line 84 def render_field_values(values, field_config = Configuration::NullField.new) field_values(field_config, value: Array(values)) end |
#render_index_field_value(*args) ⇒ Object
Deprecated.
72 73 74 |
# File 'app/presenters/blacklight/index_presenter.rb', line 72 def render_index_field_value(*args) field_value(*args) end |
#render_values(values, field_config = Configuration::NullField.new) ⇒ Object
Deprecated.
90 91 92 |
# File 'app/presenters/blacklight/index_presenter.rb', line 90 def render_values(values, field_config = Configuration::NullField.new) field_values(field_config, value: Array(values)) end |