Class: FacetedSearch::Facets::Default

Inherits:
Object
  • Object
show all
Defined in:
app/models/faceted_search/facets/default.rb

Direct Known Subclasses

Filter, Search

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, params:, facets:, find_by: nil, source: nil, habtm: false, title: nil) ⇒ Default

Returns a new instance of Default.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/faceted_search/facets/default.rb', line 5

def initialize( name:,
                params:,
                facets:,
                find_by: nil,
                source: nil,
                habtm: false,
                title: nil)
  @name = name
  @title = title
  @params = params
  @facets = facets
  @find_by = find_by
  @source = source
  @habtm = habtm
end

Instance Attribute Details

#facetsObject (readonly)

Returns the value of attribute facets.



3
4
5
# File 'app/models/faceted_search/facets/default.rb', line 3

def facets
  @facets
end

#find_byObject (readonly)

Returns the value of attribute find_by.



3
4
5
# File 'app/models/faceted_search/facets/default.rb', line 3

def find_by
  @find_by
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'app/models/faceted_search/facets/default.rb', line 3

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'app/models/faceted_search/facets/default.rb', line 3

def params
  @params
end

Instance Method Details

#add_scope(scope) ⇒ Object



33
34
35
36
# File 'app/models/faceted_search/facets/default.rb', line 33

def add_scope(scope)
  # Override
  scope
end

#kindObject



25
26
27
# File 'app/models/faceted_search/facets/default.rb', line 25

def kind
  self.class.to_s
end

#path(custom_params = @params) ⇒ Object



38
39
40
41
# File 'app/models/faceted_search/facets/default.rb', line 38

def path(custom_params = @params)
  return '' if custom_params.blank?
  "&facets[#{@name}]=#{custom_params}"
end

#path_for(value) ⇒ Object



29
30
31
# File 'app/models/faceted_search/facets/default.rb', line 29

def path_for(value)
  "&facets[#{name}]=#{value}"
end

#titleObject



21
22
23
# File 'app/models/faceted_search/facets/default.rb', line 21

def title
  @title ||= name.to_s.humanize.titleize
end

#to_sObject



43
44
45
# File 'app/models/faceted_search/facets/default.rb', line 43

def to_s
  "#{title}"
end