Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
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
shotengai
Commits
db7b6b48
Commit
db7b6b48
authored
6 years ago
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hahaha
parent
09d97099
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletion
+33
-1
product.rb
lib/shotengai/product.rb
+33
-1
No files found.
lib/shotengai/product.rb
View file @
db7b6b48
...
...
@@ -126,7 +126,39 @@ module Shotengai
# Will get methods:
# "#{tag_name}_list" tag_name is singular
# tagger_with('xx', on: "#{tag_name}.to_sym): tag_name is plural
include
JoinCatalog
# include JoinCatalog
def
join_catalog_system
catalog_class_name
,
options
=
{}
catalog_class
=
catalog_class_name
.
constantize
tag_name
=
options
[
:as
]
||
catalog_class
.
model_name
.
singular
acts_as_taggable_on
tag_name
.
to_sym
list_name
=
"
#{
tag_name
}
_list"
.
to_sym
class_eval
do
# define_method("#{tag_name}_list=") { |value|
# super catalog_class.validate_name_chain(value)
# }
scope
"
#{
list_name
}
_filter"
.
to_sym
,
->
(
catalogs
)
{
tags
=
catalogs
&&
catalogs
.
try
(
:tag
)
||
catalogs
.
any?
&&
catalogs
&
.
map
(
&
:tag
)
tags
?
tagged_with
(
tags
,
on:
list_name
)
:
all
}
define_method
(
"
#{
tag_name
}
_ids="
)
{
|
ids
|
send
(
"
#{
list_name
}
="
,
catalog_class
.
ids_to_tags
(
ids
))
}
define_method
(
"
#{
tag_name
}
_ids"
)
{
send
(
list_name
).
map
(
&
:id
)
}
define_method
(
"
#{
tag_name
}
_names"
)
{
send
(
list_name
).
map
(
&
:name
)
}
define_method
(
list_name
)
{
catalog_class
.
unscope
(
:order
).
where
(
id:
super
().
map
{
|
tag
|
Shotengai
::
Catalog
.
parse_tag
(
tag
)
}).
order
(
:nested_level
)
}
end
end
end
end
end
This diff is collapsed.
Click to expand it.
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