Commit 1675501c by ivan Lan

Add catalog_ids to Product

parent 98f4cee7
...@@ -19,6 +19,7 @@ module Shotengai ...@@ -19,6 +19,7 @@ module Shotengai
# manager_type :string(255) # manager_type :string(255)
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
# remark :json
# #
# Indexes # Indexes
# #
...@@ -133,8 +134,16 @@ module Shotengai ...@@ -133,8 +134,16 @@ module Shotengai
send("#{list_name}=", catalog_class.ids_to_tags(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) { define_method(list_name) {
catalog_class.where(id: super().map { |tag| Shotengai::Catalog.parse_tag(tag) }).select(:name).map(&:name) catalog_class.where(id: super().map { |tag| Shotengai::Catalog.parse_tag(tag) })
} }
end end
......
...@@ -93,6 +93,14 @@ module Shotengai ...@@ -93,6 +93,14 @@ module Shotengai
full_meta['snapshot'] || {} full_meta['snapshot'] || {}
end end
def product_meta
full_meta['product']
end
def series_meta
full_meta['series']
end
def meta= val def meta= val
self.full_meta = full_meta.merge('snapshot' => val) self.full_meta = full_meta.merge('snapshot' => val)
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