Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
acts_as_pasting
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
acts_as_pasting
Commits
0e30fc83
Commit
0e30fc83
authored
Jun 27, 2020
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove wrong files
parent
e23bc7b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
40 deletions
+4
-40
pastable.rb
lib/acts_as_pasting/pastable.rb
+4
-0
pasteable.rb
lib/acts_as_pasting/pasteable.rb
+0
-40
No files found.
lib/acts_as_pasting/pastable.rb
View file @
0e30fc83
...
...
@@ -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
lib/acts_as_pasting/pasteable.rb
deleted
100644 → 0
View file @
e23bc7b1
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment