Class: Spotlight::Appearance
- Inherits:
-
Object
- Object
- Spotlight::Appearance
- Extended by:
- ActiveModel::Naming, ActiveModel::Translation
- Includes:
- ActiveModel::Conversion
- Defined in:
- app/forms/spotlight/appearance.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
-
#document_index_view_types ⇒ Object
This enables us to have a group of checkboxes that is backed by the array stored in Spotlight::BlacklightConfiguration#document_index_view_types.
- #errors ⇒ Object
-
#initialize(configuration) ⇒ Appearance
constructor
A new instance of Appearance.
- #per_page_options ⇒ Object
- #update(params) ⇒ Object
- #view_type_options ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Appearance
Returns a new instance of Appearance.
7 8 9 |
# File 'app/forms/spotlight/appearance.rb', line 7 def initialize(configuration) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
11 12 13 |
# File 'app/forms/spotlight/appearance.rb', line 11 def configuration @configuration end |
Instance Method Details
#document_index_view_types ⇒ Object
This enables us to have a group of checkboxes that is backed by the array stored in Spotlight::BlacklightConfiguration#document_index_view_types
20 21 22 23 24 25 26 27 |
# File 'app/forms/spotlight/appearance.rb', line 20 def document_index_view_types vals = configuration.document_index_view_types Blacklight::OpenStructWithHashAccess.new.tap do |s| .each do |k| s[k] = vals.include?(k.to_s) end end end |
#errors ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/forms/spotlight/appearance.rb', line 43 def errors errors = ActiveModel::Errors.new(self) (configuration.exhibit.errors.to_a + configuration.errors.to_a).each do |e| errors.add :base, e end errors end |
#per_page_options ⇒ Object
39 40 41 |
# File 'app/forms/spotlight/appearance.rb', line 39 def default_blacklight_config.per_page end |
#update(params) ⇒ Object
29 30 31 32 33 |
# File 'app/forms/spotlight/appearance.rb', line 29 def update(params) exhibit_status = configuration.exhibit.update(exhibit_params(params)) configuration_status = configuration.update(configuration_params(params)) exhibit_status && configuration_status end |
#view_type_options ⇒ Object
35 36 37 |
# File 'app/forms/spotlight/appearance.rb', line 35 def default_blacklight_config.view.select { |k,v| v.if != false }.keys end |