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
2cbf27e2
Commit
2cbf27e2
authored
Aug 25, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use constantize instead of Object.const_get
parent
04c3d4e2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
21 deletions
+21
-21
.rspec_status
.rspec_status
+16
-16
buyer.rb
lib/shotengai/buyer.rb
+1
-1
order.rb
lib/shotengai/order.rb
+1
-1
product.rb
lib/shotengai/product.rb
+2
-2
models_spec.rb
spec/shotengai/models_spec.rb
+0
-1
spec_helper.rb
spec/spec_helper.rb
+1
-0
No files found.
.rspec_status
View file @
2cbf27e2
example_id | status | run_time |
------------------------------------------ | ------ | --------------- |
./spec/shotengai/models_spec.rb[1:1:1:1] |
failed | 0.20529
seconds |
./spec/shotengai/models_spec.rb[1:1:1:2] |
failed | 0.16928
seconds |
./spec/shotengai/models_spec.rb[1:1:2:1] |
failed | 0.16917
seconds |
./spec/shotengai/models_spec.rb[1:1:2:2] |
failed | 0.1559 seconds
|
./spec/shotengai/models_spec.rb[1:1:2:3] |
failed | 0.16818
seconds |
./spec/shotengai/models_spec.rb[1:1:3:1] |
failed | 0.17072
seconds |
./spec/shotengai/models_spec.rb[1:1:3:2] |
failed | 0.17477
seconds |
./spec/shotengai/models_spec.rb[1:1:3:3] |
failed | 0.16544
seconds |
./spec/shotengai/models_spec.rb[1:1:4:1] |
failed | 0.1618 seconds
|
./spec/shotengai/models_spec.rb[1:1:5:1] |
failed | 0.15564
seconds |
./spec/shotengai/models_spec.rb[1:1:5:2:1] |
failed | 0.15182
seconds |
./spec/shotengai/models_spec.rb[1:1:5:2:2] |
failed | 0.16236
seconds |
./spec/shotengai/models_spec.rb[1:2:1:1] |
failed | 0.17459
seconds |
./spec/shotengai/models_spec.rb[1:2:1:2] |
failed | 0.18331
seconds |
./spec/shotengai/models_spec.rb[1:2:2:1] | passed | 0.
61428
seconds |
./spec/shotengai/models_spec.rb[1:2:2:2] |
failed | 0.15561
seconds |
./spec/shotengai/models_spec.rb[1:1:1:1] |
passed | 0.44582
seconds |
./spec/shotengai/models_spec.rb[1:1:1:2] |
passed | 0.20555
seconds |
./spec/shotengai/models_spec.rb[1:1:2:1] |
passed | 0.20124
seconds |
./spec/shotengai/models_spec.rb[1:1:2:2] |
passed | 0.17955 seconds
|
./spec/shotengai/models_spec.rb[1:1:2:3] |
passed | 0.17157
seconds |
./spec/shotengai/models_spec.rb[1:1:3:1] |
passed | 0.19801
seconds |
./spec/shotengai/models_spec.rb[1:1:3:2] |
passed | 0.18172
seconds |
./spec/shotengai/models_spec.rb[1:1:3:3] |
passed | 0.17998
seconds |
./spec/shotengai/models_spec.rb[1:1:4:1] |
passed | 0.23986 seconds
|
./spec/shotengai/models_spec.rb[1:1:5:1] |
passed | 0.17938
seconds |
./spec/shotengai/models_spec.rb[1:1:5:2:1] |
passed | 0.24027
seconds |
./spec/shotengai/models_spec.rb[1:1:5:2:2] |
passed | 0.21941
seconds |
./spec/shotengai/models_spec.rb[1:2:1:1] |
passed | 0.20203
seconds |
./spec/shotengai/models_spec.rb[1:2:1:2] |
passed | 0.21369
seconds |
./spec/shotengai/models_spec.rb[1:2:2:1] | passed | 0.
43436
seconds |
./spec/shotengai/models_spec.rb[1:2:2:2] |
passed | 0.28966
seconds |
lib/shotengai/buyer.rb
View file @
2cbf27e2
...
...
@@ -7,7 +7,7 @@ module Shotengai
class_methods
do
def
can_shopping_with
klass_name
,
options
=
{}
klass
=
Object
.
const_get
(
klass_name
)
klass
=
klass_name
.
constantize
unless
Shotengai
::
Order
<=>
klass
# 为子类
raise
ArgumentError
.
new
(
'You can only buy the class inherit from Shotengai::Order'
)
end
...
...
lib/shotengai/order.rb
View file @
2cbf27e2
...
...
@@ -84,7 +84,7 @@ module Shotengai
end
def
can_buy
*
good_class_names
good_classes
=
good_class_names
.
map
{
|
name
|
Object
.
const_get
(
name
)
}
good_classes
=
good_class_names
.
map
(
&
:constantize
)
# 所有snapshot
has_many
:snapshots
,
->
{
where
(
type:
good_classes
.
map
{
|
good_class
|
"
#{
good_class
.
name
}
Snapshot"
})
...
...
lib/shotengai/product.rb
View file @
2cbf27e2
...
...
@@ -53,8 +53,8 @@ module Shotengai
class ::
#{
subclass
}
Snapshot < Shotengai::Snapshot; end
"
)
subclass
.
instance_eval
do
def
series_class
;
Object
.
const_get
"
#{
self
.
name
}
Series"
;
end
def
snapshot_class
;
Object
.
const_get
"
#{
self
.
name
}
Snapshot"
;
end
def
series_class
;
"
#{
self
.
name
}
Series"
.
constantize
;
end
def
snapshot_class
;
"
#{
self
.
name
}
Snapshot"
.
constantize
;
end
end
end
...
...
spec/shotengai/models_spec.rb
View file @
2cbf27e2
...
...
@@ -15,7 +15,6 @@ c.exec_update('drop database if exists shotengai_test;')
c
.
exec_update
(
'create database shotengai_test'
)
c
.
exec_update
(
'use shotengai_test'
)
# 如何通过activerecord 建database
RSpec
.
describe
'Shotengai Models'
do
before
do
ActiveRecord
::
Migration
[
5.1
].
subclasses
.
each
do
|
migrate
|
...
...
spec/spec_helper.rb
View file @
2cbf27e2
require
"bundler/setup"
require
'rails'
require
'active_record'
require
'shotengai'
require
'support/factory_girl'
# Dir['../support/**/*.rb'].each { |f| require f }
...
...
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