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
40086791
Commit
40086791
authored
Aug 12, 2020
by
Ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix pasted with any if arg is empty array
parent
23a9a168
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
pasted.rb
lib/acts_as_pasting/pasted.rb
+9
-8
No files found.
lib/acts_as_pasting/pasted.rb
View file @
40086791
...
...
@@ -9,6 +9,7 @@ module ActsAsPasting
# ary => [obj, obj]
scope
:pasted_with_any
,
->
(
ary
,
prefix:
''
)
{
ary
=
parsed_condition_ary
(
ary
)
return
none
unless
ary
.
first
arel
=
Arel
::
Table
.
new
(
:acts_as_pasting_pastings
,
as:
"acts_as_pasting_pastings_
#{
SecureRandom
.
hex
(
10
)
}
"
)
source_arel
=
arel_table
join_condition
=
ary
.
group_by
(
&
:first
).
map
do
|
(
klass
,
value
)
|
...
...
@@ -68,14 +69,14 @@ module ActsAsPasting
remove_ary
.
each
{
|
klass
,
id
|
pastings
.
where
(
type:
''
,
pasted:
self
,
pasteable_type:
klass
,
pasteable_type:
klass
,
pasteable_id:
id
).
destroy_all
}
add_ary
.
each
{
|
klass
,
id
|
pastings
.
create!
(
type:
''
,
pasted:
self
,
pasteable_type:
klass
,
pasted:
self
,
pasteable_type:
klass
,
pasteable_id:
id
)
}
...
...
@@ -85,7 +86,7 @@ module ActsAsPasting
# def method_missing name, *arg, &block
# klass_downcase = /^paste_(.+)_list$/.match(name)&.[](1)
# if klass_downcase
# downcase_all_combination(klass_downcase).each do |str|
# return paste_list_for(str) if correct_class_name?(str)
...
...
@@ -150,7 +151,7 @@ module ActsAsPasting
end
def paste_
#{
downcase
}
_list= ary, run_save: true
ary = self.class.parsed_condition_ary(ary).select { |a|
ary = self.class.parsed_condition_ary(ary).select { |a|
a.first == "
#{
base_class_name
}
"
}
if new_record?
...
...
@@ -166,14 +167,14 @@ module ActsAsPasting
remove_ary.each { |klass, id| pastings.where(
type: "
#{
type_value
}
",
pasted: self,
pasteable_type: klass,
pasteable_type: klass,
pasteable_id: id
).destroy_all
}
add_ary.each { |klass, id| pastings.create!(
type: "
#{
type_value
}
",
pasted: self,
pasteable_type: klass,
pasted: self,
pasteable_type: klass,
pasteable_id: id
)
}
...
...
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