Class: FriendlyId::ActiveRecordAdapter::Relation::Find
- Extended by:
- Forwardable
- Defined in:
- lib/friendly_id/active_record_adapter/relation.rb
Instance Attribute Summary collapse
-
#ids ⇒ Object
(also: #id)
readonly
Returns the value of attribute ids.
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
Instance Method Summary collapse
- #find_one ⇒ Object
- #find_some ⇒ Object
-
#initialize(relation, ids) ⇒ Find
constructor
A new instance of Find.
Constructor Details
#initialize(relation, ids) ⇒ Find
Returns a new instance of Find.
16 17 18 19 |
# File 'lib/friendly_id/active_record_adapter/relation.rb', line 16 def initialize(relation, ids) @relation = relation @ids = ids end |
Instance Attribute Details
#ids ⇒ Object (readonly) Also known as: id
Returns the value of attribute ids.
9 10 11 |
# File 'lib/friendly_id/active_record_adapter/relation.rb', line 9 def ids @ids end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
8 9 10 |
# File 'lib/friendly_id/active_record_adapter/relation.rb', line 8 def relation @relation end |
Instance Method Details
#find_one ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/friendly_id/active_record_adapter/relation.rb', line 21 def find_one if fc.cache_column? find_one_with_cached_slug elsif fc.use_slugs? find_one_with_slug else find_one_without_slug end end |
#find_some ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/friendly_id/active_record_adapter/relation.rb', line 31 def find_some ids = @ids.compact.uniq.map {|id| id.respond_to?(:friendly_id_config) ? id.id.to_i : id} friendly_ids, unfriendly_ids = ids.partition {|id| id.friendly_id?} return if friendly_ids.empty? records = friendly_records(friendly_ids, unfriendly_ids).each do |record| record.friendly_id_status.name = ids end validate_expected_size!(ids, records) end |