Commit 98f4cee7 by ivan Lan

Separate the snapshot own meta from the meta come from its product and series

parent 2c35a499
......@@ -211,6 +211,7 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
meta: { type: :object },
incr_snapshot_ids: { type: :array },
},
}
snapshot: {
type: :object, properties: {
shotengai_series_id: { type: :integer },
......@@ -219,7 +220,6 @@ RSpec.describe "#{namespace}/orders", type: :request, capture_examples: true, ta
}
}
}
}
response(201, description: 'successful') do
let(:order_and_snapshot_params) {
......
......@@ -16,8 +16,6 @@ module Shotengai
define_method("#{column}_input=") do |val|
parsed_val = val && val.map{ |h| { (h[:key] || h['key']) => (h[:val] || h['val']) } }.reduce(&:merge)
self.#{column} = parsed_val
# self.assign_attributes('#{column}' => parsed_val)
end
define_method("#{column}_output") do
......
......@@ -80,8 +80,21 @@ module Shotengai
define_method(column) { read_attribute(column) || self.series.send(column) }
end
def full_meta
read_attribute(:meta) || {}
end
def full_meta= val
write_attribute(:meta, val)
end
def meta
read_attribute(:meta) || (series.product.meta || {} ).merge(series.meta || {})
full_meta['snapshot'] || {}
end
def meta= val
self.full_meta = full_meta.merge('snapshot' => val)
end
def already_disable
......@@ -111,7 +124,11 @@ module Shotengai
banners: series.banners,
cover_image: series.cover_image,
detail: series.detail,
meta: (product.meta || {} ).merge(series.meta || {})
full_meta: {
product: product.meta,
series: series.meta,
snapshot: meta,
}
)
end
......@@ -138,12 +155,6 @@ module Shotengai
def order_status; shotengai_order&.status end
def order_status_zh; shotengai_order&.status_zh end
######
def meta
super || {}
end
private
# spec 字段
def check_spec
......
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