Class: FriendlyId::ActiveRecordAdapter::Finders::FinderProxy

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/friendly_id/active_record_adapter/finders.rb

Overview

FinderProxy is used to choose which finder class to instantiate; depending on the model_class’s friendly_id_config and the options passed into the constructor, it will decide whether to use simple or slugged finder, a single or multiple finder, and in the case of slugs, a cached or uncached finder.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_class, *args, &block) ⇒ FinderProxy

Returns a new instance of FinderProxy.



29
30
31
32
33
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 29

def initialize(model_class, *args, &block)
  @model_class = model_class
  @ids = args.shift
  @options = args.first.kind_of?(Hash) ? args.first : {}
end

Instance Attribute Details

#finderObject (readonly)

Perform the find query.



36
37
38
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 36

def finder
  @finder
end

#finder_classObject (readonly)

Returns the value of attribute finder_class.



22
23
24
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 22

def finder_class
  @finder_class
end

#idsObject (readonly)

Returns the value of attribute ids.



23
24
25
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 23

def ids
  @ids
end

#model_classObject (readonly)

Returns the value of attribute model_class.



24
25
26
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 24

def model_class
  @model_class
end

#optionsObject (readonly)

Returns the value of attribute options.



25
26
27
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 25

def options
  @options
end

Instance Method Details

#multiple?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 44

def multiple?
  ids.kind_of? Array
end