Class: Spotlight::Appearance

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming, ActiveModel::Translation
Includes:
ActiveModel::Conversion
Defined in:
app/forms/spotlight/appearance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configurationObject (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_typesObject

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|
    view_type_options.each do |k|
      s[k] = vals.include?(k.to_s)
    end
  end
end

#errorsObject



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_optionsObject



39
40
41
# File 'app/forms/spotlight/appearance.rb', line 39

def per_page_options
  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_optionsObject



35
36
37
# File 'app/forms/spotlight/appearance.rb', line 35

def view_type_options
  default_blacklight_config.view.select { |k,v| v.if != false }.keys
end