Commit 0e30fc83 by liyijie

remove wrong files

parent e23bc7b1
......@@ -31,6 +31,10 @@ module ActsAsPasting
end
module ClassMethods
def acts_as_pastable associations, options={}
has_many :pastings, as: :pasteable, class_name: 'ActsAsPasting::Pasting'
has_many associations, through: :pastings, source: :pasted, **options
end
end
end
end
module ActsAsPasting
module Pasteable
extend ActiveSupport::Concern
# 带 prefix 的 pasted_with,独立于不带 prefix 的之外
included do
has_many :pastings, as: :pasteable, class_name: 'ActsAsPasting::Pasting'
has_many :hosts, through: :pastings
# ary => [[klass, id], [klass, id]]
# ary => [obj, obj]
scope :pasted_with_any, ->(ary, prefix: '') {
ary = parsed_condition_ary(ary)
ids = ary.map do |klass, id|
joins(:pastings).where(acts_as_pasting_pastings: {
pasted_type: klass.constantize.base_class.name, pasted_id: id, type: prefix
}).pluck(:id)
end.reduce(:|)
where(id: ids)
}
scope :pasted_with_all, ->(ary, prefix: '') {
ary = parsed_condition_ary(ary)
ids = ary.map do |klass, id|
joins(:pastings).where(acts_as_pasting_pastings: {
pasted_type: klass.constantize.base_class.name, pasted_id: id, type: prefix
}).pluck(:id)
end.reduce(:&)
where(id: ids)
}
end
module ClassMethods
def acts_as_pastable associations, options={}
has_many :pastings, as: :pasteable, class_name: 'ActsAsPasting::Pasting'
has_many associations, through: :pastings, source: :pasted, **options
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment