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
6d68782d
Commit
6d68782d
authored
Oct 16, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate the product & series views template & Fix bug cause for the new json column changes
parent
cea424ab
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
9 deletions
+14
-9
harray.rb
lib/shotengai/harray.rb
+7
-2
json_column.rb
lib/shotengai/json_column.rb
+5
-5
series.rb
lib/shotengai/series.rb
+1
-1
snapshot.rb
lib/shotengai/snapshot.rb
+1
-1
No files found.
lib/shotengai/harray.rb
View file @
6d68782d
...
...
@@ -3,17 +3,22 @@ module Shotengai
class
<<
self
def
encode
hash
Harray
.
new
(
if
hash
.
is_a?
(
Hash
)
hash
.
map
{
|
key
,
val
|
{
'key'
=>
key
,
'val'
=>
val
}
}
else
Array
(
hash
)
end
)
end
def
decode
harray
harray
&&
Harray
.
new
(
harray
).
decode
Harray
.
encode
(
harray
).
decode
end
end
# def initialize
# def initialize
*arg, &block
# # Add some validations
# BUT HOW?
# end
def
keys
...
...
lib/shotengai/json_column.rb
View file @
6d68782d
...
...
@@ -11,7 +11,7 @@ module Shotengai
class_eval
%Q{
def
#{
column
}
= val
raise Shotengai::WebError.new('
#{
column
}
必须是个 Array', -1 , 401) unless val.nil? || Array === val
super(
#{
decode
}
? Harray.decode(val) : val)
super(
#{
decode
}
?
Shotengai::
Harray.decode(val) : val)
end
}
end
...
...
@@ -38,7 +38,7 @@ module Shotengai
class_eval
%Q{
def
#{
key
}
{
template:
#{
template
}
,
template:
Shotengai::Harray.encode(
#{
template
}
).keys
,
value:
#{
value
}
,
}
end
...
...
@@ -51,7 +51,7 @@ module Shotengai
end
keys
.
each
do
|
key
|
value
=
value_in_template
?
"
#{
key
}
_template.decode
"
:
"
#{
key
}
_value"
value
=
value_in_template
?
"
Shotengai::Harray.decode(
#{
key
}
_template)
"
:
"
#{
key
}
_value"
self
.
template_with_value
key
,
value:
value
end
end
...
...
@@ -69,11 +69,11 @@ module Shotengai
raise Shotengai::WebError.new('
#{
chimera
}
必须是个 Hash', -1 , 401) unless val.nil? || Hash === val
write_attribute(:
#{
column
}
, val)
end
# TODO: WARNING: 这里也 没有继承 之前方法的解析
def
#{
column
}
_before_implant
#{
column
}
end
# WARNING: 默认值为 {}
define_method('
#{
column
}
') do
#{
chimera
}
['
#{
as
}
'] || {}
end
...
...
lib/shotengai/series.rb
View file @
6d68782d
...
...
@@ -40,7 +40,7 @@ module Shotengai
harray_accessor
:info_template
,
:detail_info_template
harray_accessor
:spec_value
,
:remark_value
,
decode:
true
template_with_value_getters
:info
,
value_in_template:
true
template_with_value_getters
:info
,
:detail_info
,
value_in_template:
true
template_with_value_getters
:spec
,
:remark
,
delegate_template_to: :product
# full_info_template: { optional: d, detail: detail_info_template }
...
...
lib/shotengai/snapshot.rb
View file @
6d68782d
...
...
@@ -38,7 +38,7 @@ module Shotengai
validate
:check_remark_value
,
unless: :remark_template_empty?
validates
:count
,
numericality:
{
only_integer:
true
,
greater_than:
0
}
template_with_value_getters
:spec
,
:remark
,
:info
,
delegate_template_to: :series
template_with_value_getters
:spec
,
:remark
,
:info
,
:detail_info
,
delegate_template_to: :series
column_has_implants
:meta
,
implants:
[
'product'
,
'series'
],
as: :snapshot
column_has_implants
:info_value
,
implants:
[
'detail'
],
as: :snapshot
...
...
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