class ActiveRecord::Associations::CollectionProxy

Public Instance Methods

hobo_association_collection?() click to toggle source
# File lib/hobo/extensions/active_record/associations/collection.rb, line 8
def hobo_association_collection?
  Hobo::Model.in?(proxy_association.owner.class.included_modules)
end
is_a?(klass) click to toggle source
# File lib/hobo/extensions/active_record/associations/collection.rb, line 28
def is_a?(klass)
  if has_one_collection?
    load_target
    proxy_association.target.is_a?(klass)
  else
    [].is_a?(klass)
  end
end
member_class() click to toggle source
# File lib/hobo/extensions/active_record/associations/collection.rb, line 37
def member_class
  proxy_association.reflection.klass
end
method_missing_with_origin(method, *args, &block) click to toggle source

FIXME Ralis4: really hoping that we can replace this with something based on github.com/rails/rails/issues/5717 def scoped_with_origin

relation = scoped_without_origin.clone
relation.origin = proxy_association.owner
relation.origin_attribute = proxy_association.reflection.name
relation

end alias_method_chain :scoped, :origin

# File lib/hobo/extensions/active_record/relation_with_origin.rb, line 37
def method_missing_with_origin(method, *args, &block)
  res = method_missing_without_origin(method, *args, &block)
  res.origin = proxy_association.owner if res.respond_to?(:origin)
  res.origin_attribute = proxy_association.reflection.name if res.respond_to?(:origin_attribute)
  res
end
new_candidate(attributes = {}) click to toggle source
# File lib/hobo/extensions/active_record/associations/collection.rb, line 13
def new_candidate(attributes = {})
  record = new
  proxy_association.target.delete record
  set_reverse_association(record) if hobo_association_collection?
  record
end
user_new_candidate(user, attributes = {}) click to toggle source
# File lib/hobo/extensions/active_record/associations/collection.rb, line 21
def user_new_candidate(user, attributes = {})
  record = user_new(user, attributes)
  proxy_association.target.delete record
  set_reverse_association(record) if hobo_association_collection?
  record
end