class SelfishAssociations::ScopeReaders::Relation
Attributes
attributes_for_create[R]
conditions_for_find[R]
traverser[R]
Public Class Methods
new(klass)
click to toggle source
# File lib/selfish_associations/scope_readers/relation.rb, line 22 def initialize(klass) @traverser = ::SelfishAssociations::AssociationTraverser.new(klass) @conditions_for_find = {} @joins_for_find = [] @attributes_for_create = {} @joins_for_create = [] end
Public Instance Methods
create_with(conditions)
click to toggle source
# File lib/selfish_associations/scope_readers/relation.rb, line 45 def create_with(conditions) @attributes_for_create.merge!(conditions) @joins_for_create += @traverser.associations!(merge: false) @traverser.reset! return self end
joins_for_create()
click to toggle source
# File lib/selfish_associations/scope_readers/relation.rb, line 56 def joins_for_create ::SelfishAssociations::PathMerger.new(@joins_for_create).merge end
joins_for_find()
click to toggle source
# File lib/selfish_associations/scope_readers/relation.rb, line 52 def joins_for_find ::SelfishAssociations::PathMerger.new(@joins_for_find).merge end
read(scope)
click to toggle source
# File lib/selfish_associations/scope_readers/relation.rb, line 30 def read(scope) args = scope.arity == 0 ? [] : [@traverser] instance_exec(*args, &scope) return self end
where(conditions)
click to toggle source
TODO: implement argless where() and not()
# File lib/selfish_associations/scope_readers/relation.rb, line 37 def where(conditions) create_with(conditions) @conditions_for_find.merge!(conditions) @joins_for_find += @traverser.associations!(merge: false) @traverser.reset! return self end