Class: FriendlyId::ActiveRecordAdapter::Finders::Find
- Extended by:
- Forwardable
- Defined in:
- lib/friendly_id/active_record_adapter/finders.rb
Instance Attribute Summary collapse
-
#friendly_ids ⇒ Object
readonly
Returns the value of attribute friendly_ids.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#unfriendly_ids ⇒ Object
readonly
Returns the value of attribute unfriendly_ids.
Instance Method Summary collapse
- #find_one ⇒ Object
- #find_some ⇒ Object
-
#initialize(klass, id, options) ⇒ Find
constructor
A new instance of Find.
Constructor Details
#initialize(klass, id, options) ⇒ Find
Returns a new instance of Find.
19 20 21 22 23 24 25 26 27 |
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 19 def initialize(klass, id, ) @klass = klass @id = id @options = if [:scope] raise "The :scope finder option has been removed from FriendlyId 3.2.0 " + "https://github.com/norman/friendly_id/issues#issue/88" end end |
Instance Attribute Details
#friendly_ids ⇒ Object (readonly)
Returns the value of attribute friendly_ids.
16 17 18 |
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 16 def friendly_ids @friendly_ids end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 13 def id @id end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
12 13 14 |
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 12 def klass @klass end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 14 def @options end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
15 16 17 |
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 15 def result @result end |
#unfriendly_ids ⇒ Object (readonly)
Returns the value of attribute unfriendly_ids.
17 18 19 |
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 17 def unfriendly_ids @unfriendly_ids end |
Instance Method Details
#find_one ⇒ Object
29 30 31 32 33 34 |
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 29 def find_one return find_one_with_cached_slug if !fc.scope? && cache_column? return find_one_with_slug if use_slugs? @result = scoped(:conditions => ["#{table_name}.#{fc.column} = ?", id]).first() assign_status end |
#find_some ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/friendly_id/active_record_adapter/finders.rb', line 36 def find_some parse_ids! scope = some_friendly_scope if use_slugs? && @friendly_ids.present? scope = scope.scoped(:joins => :slugs) end [:readonly] = false unless [:readonly] @result = scope.all().uniq validate_expected_size! @result.each { |record| record.friendly_id_status.name = id } end |