Class: SearchMagic::Breadcrumb

Inherits:
Object
  • Object
show all
Defined in:
lib/search_magic/breadcrumb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field_name, options) ⇒ Breadcrumb

Returns a new instance of Breadcrumb.



5
6
7
8
9
10
# File 'lib/search_magic/breadcrumb.rb', line 5

def initialize(field_name, options)
  self.field_name = field_name
  self.options = options
  self.options[:except] = Array.wrap(self.options[:except]).compact
  self.options[:only] = Array.wrap(self.options[:only]).compact
end

Instance Attribute Details

#field_nameObject

Returns the value of attribute field_name.



3
4
5
# File 'lib/search_magic/breadcrumb.rb', line 3

def field_name
  @field_name
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/search_magic/breadcrumb.rb', line 3

def options
  @options
end

Instance Method Details

#cloneObject



16
17
18
# File 'lib/search_magic/breadcrumb.rb', line 16

def clone
  Breadcrumb.new(field_name, options)
end

#termObject



12
13
14
# File 'lib/search_magic/breadcrumb.rb', line 12

def term
  @term ||= options[:skip_prefix].presence ? nil : (options[:as] || field_name.to_s.pluralize.singularize).to_sym
end