Class: AmsLazyRelationships::Loaders::SimpleBelongsTo
- Defined in:
- lib/ams_lazy_relationships/loaders/simple_belongs_to.rb
Overview
Batch loads parent ActiveRecord records for given record by foreign key. Useful when the relationship is not a standard ActiveRecord relationship.
Instance Method Summary collapse
-
#initialize(association_class_name, foreign_key: "#{association_class_name.underscore}_id") ⇒ SimpleBelongsTo
constructor
A new instance of SimpleBelongsTo.
Methods inherited from Base
Constructor Details
#initialize(association_class_name, foreign_key: "#{association_class_name.underscore}_id") ⇒ SimpleBelongsTo
Returns a new instance of SimpleBelongsTo.
15 16 17 18 19 20 21 |
# File 'lib/ams_lazy_relationships/loaders/simple_belongs_to.rb', line 15 def initialize( association_class_name, foreign_key: "#{association_class_name.underscore}_id" ) @association_class_name = association_class_name @foreign_key = foreign_key.to_sym end |