Class: BlacklightIiifSearch::IiifSearch

Inherits:
Object
  • Object
show all
Includes:
SearchBehavior
Defined in:
app/models/blacklight_iiif_search/iiif_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SearchBehavior

#object_relation_solr_params

Constructor Details

#initialize(params, iiif_search_config, parent_document) ⇒ IiifSearch

Returns a new instance of IiifSearch.

Parameters:

  • params (Hash)
  • iiif_search_config (Hash)
  • parent_document (SolrDocument)


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/blacklight_iiif_search/iiif_search.rb', line 14

def initialize(params, iiif_search_config, parent_document)
  @id = params[:solr_document_id]
  @iiif_config = iiif_search_config
  @parent_document = parent_document
  @q = params[:q]
  @page = params[:page]
  @rows = 50

  # NOT IMPLEMENTED YET
  # @motivation = params[:motivation]
  # @date = params[:date]
  # @user = params[:user]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'app/models/blacklight_iiif_search/iiif_search.rb', line 8

def id
  @id
end

#iiif_configObject (readonly)

Returns the value of attribute iiif_config.



8
9
10
# File 'app/models/blacklight_iiif_search/iiif_search.rb', line 8

def iiif_config
  @iiif_config
end

#pageObject (readonly)

Returns the value of attribute page.



8
9
10
# File 'app/models/blacklight_iiif_search/iiif_search.rb', line 8

def page
  @page
end

#parent_documentObject (readonly)

Returns the value of attribute parent_document.



8
9
10
# File 'app/models/blacklight_iiif_search/iiif_search.rb', line 8

def parent_document
  @parent_document
end

#qObject (readonly)

Returns the value of attribute q.



8
9
10
# File 'app/models/blacklight_iiif_search/iiif_search.rb', line 8

def q
  @q
end

#rowsObject (readonly)

Returns the value of attribute rows.



8
9
10
# File 'app/models/blacklight_iiif_search/iiif_search.rb', line 8

def rows
  @rows
end

Instance Method Details

#solr_paramsHash

return a hash of Solr search params if q is not supplied, have to pass some dummy params or else all records matching object_relation_solr_params are returned

Returns:

  • (Hash)


33
34
35
36
# File 'app/models/blacklight_iiif_search/iiif_search.rb', line 33

def solr_params
  return { q: 'nil:nil' } unless q
  { q: q, f: object_relation_solr_params, rows: rows, page: page }
end