Method: ReactiveRecord::Collection#initialize
- Defined in:
- lib/reactive_record/active_record/reactive_record/collection.rb
#initialize(target_klass, owner = nil, association = nil, *vector) ⇒ Collection
Returns a new instance of Collection.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/reactive_record/active_record/reactive_record/collection.rb', line 28 def initialize(target_klass, owner = nil, association = nil, *vector) @owner = owner # can be nil if this is an outer most scope @association = association @target_klass = target_klass if owner and !owner.id and vector.length <= 1 @collection = [] elsif vector.length > 0 @vector = vector elsif owner @vector = owner.backing_record.vector + [association.attribute] else @vector = [target_klass] end @scopes = {} end |