This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
## | |
## denfine spec() simply | |
## | |
use strict; | |
use warnings; | |
sub spec { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
## | |
## change block arg of spec() to be optional | |
## | |
use strict; | |
use warnings; | |
use Test::More; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
## | |
## define OK() assertion function | |
## | |
use strict; | |
use warnings; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
## | |
## define topic() and case_when() functions | |
## | |
use strict; | |
use warnings; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
## | |
## enhance to build intermediate data structure | |
## | |
use strict; | |
use warnings; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
## | |
## add at_end() which registers blocks called end of test. | |
## | |
use strict; | |
use warnings; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
## | |
## define AssertionObject class | |
## | |
use strict; | |
use warnings; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
### Decorator for view function works very well. | |
### | |
def GET(route_name, template): | |
def deco(func): | |
@view_config(route_name=route_name, request_method='GET', | |
renderer='templates/'+template) | |
def fn(request): | |
# ... do something here ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from pyramid.view import view_config | |
from venusian import ATTACH_ATTR # view_config() uses 'venusian' module internally | |
## | |
## utility | |
## | |
def view_method(fn, **kwargs): | |
# get frame of class definition |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## モデルクラスから Query クラス (or Collection クラス) を分離すれば、 | |
## 黒魔術を一切使わなくても named_scope が実現できることを示すサンプル | |
class ORM::Entity | |
end | |
class ORM::Query # or ORM::Collection | |
def where(*args) ... end | |
def order_by(*args) ... end | |
def limit(n) ... end |