Class: FriendlyId::ActiveRecordAdapter::Relation::Find
- Inherits:
-
Object
- Object
- FriendlyId::ActiveRecordAdapter::Relation::Find
- Extended by:
- Forwardable
- Defined in:
- lib/friendly_id/active_record_adapter/relation.rb
Instance Attribute Summary (collapse)
-
- (Object) ids
(also: #id)
readonly
Returns the value of attribute ids.
-
- (Object) relation
readonly
Returns the value of attribute relation.
Instance Method Summary (collapse)
- - (Object) find_one
- - (Object) find_some
-
- (Find) initialize(relation, ids)
constructor
A new instance of Find.
Constructor Details
- (Find) initialize(relation, ids)
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
- (Object) ids (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 |
- (Object) relation (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
- (Object) find_one
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 |
- (Object) find_some
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 : 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 |