Class: Blacklight::ClausePresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/blacklight/clause_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, user_parameters, field_config, view_context, search_state = view_context.search_state) ⇒ ClausePresenter

Returns a new instance of ClausePresenter.



7
8
9
10
11
12
13
# File 'app/presenters/blacklight/clause_presenter.rb', line 7

def initialize(key, user_parameters, field_config, view_context, search_state = view_context.search_state)
  @key = key
  @user_parameters = user_parameters
  @field_config = field_config
  @view_context = view_context
  @search_state = search_state
end

Instance Attribute Details

#field_configObject (readonly)

Returns the value of attribute field_config.



5
6
7
# File 'app/presenters/blacklight/clause_presenter.rb', line 5

def field_config
  @field_config
end

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'app/presenters/blacklight/clause_presenter.rb', line 5

def key
  @key
end

#search_stateObject (readonly)

Returns the value of attribute search_state.



5
6
7
# File 'app/presenters/blacklight/clause_presenter.rb', line 5

def search_state
  @search_state
end

#user_parametersObject (readonly)

Returns the value of attribute user_parameters.



5
6
7
# File 'app/presenters/blacklight/clause_presenter.rb', line 5

def user_parameters
  @user_parameters
end

#view_contextObject (readonly)

Returns the value of attribute view_context.



5
6
7
# File 'app/presenters/blacklight/clause_presenter.rb', line 5

def view_context
  @view_context
end

Instance Method Details

#constraint_labelObject



27
28
29
# File 'app/presenters/blacklight/clause_presenter.rb', line 27

def constraint_label
  label
end

#field_labelObject



15
16
17
# File 'app/presenters/blacklight/clause_presenter.rb', line 15

def field_label
  field_config.display_label('search')
end

#labelString

Get the displayable version of a facet’s value

Returns:

  • (String)


23
24
25
# File 'app/presenters/blacklight/clause_presenter.rb', line 23

def label
  user_parameters[:query]
end

#remove_href(path = search_state) ⇒ Object



31
32
33
# File 'app/presenters/blacklight/clause_presenter.rb', line 31

def remove_href(path = search_state)
  view_context.search_action_path(path.reset_search(clause: path.clause_params.except(key)))
end