quattro_4 scribble

scribble 落書き (調べた事をただ落書きする)

2013-08-14から1日間の記事一覧

RubyTapas #021 - #025

021 Domain Model Events ★ around_save + yield notify_listeners(:on_create) Listeners作成 class PusherTaskListener class TaskEmailListener controller def notify_listeners(event_name, *args) @listeners && @listeners.each do |listener| if lis…

RubyTapas #120 - #124

120 Outside-In ★★ configファイルとかのテスト stdinを介したテストとか output, status = Open3.capture2() output, status = Open3.capture2e(env, %W[hostconfig -c], stdin_data: example_input) config file hosts = hosts_from_input($stdin.read) Wr…

RubyTapas #115 - #119

115 pp ★★ p = puts + .inspect pp -> pretty print indentation, nested hashes 出力を変数に格納して後で扱うことができる pretty = repo.pretty_inspect pretty puts pretty 116 Extract Command Object ★ 12分 RubyNation Conference fundamental refact…

RubyTapas #110 - #114

110 Catch And Throw ★ begin parser.parse(html) unless html.nil? rescue DoneException # we are done end ↓ catch(:done) do parser.parse(html) unless html.nil? end + throw :done perfectly normal early returns 大域脱出catch, throw知らなかった …