メタプログラミングでDSLを書こう
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

メタプログラミングでDSLを書こう

  • 4,679 views
Uploaded on

2011/07/04 に行われた株式会社スケールアウトさんとのLT大会で使用したスライドです

2011/07/04 に行われた株式会社スケールアウトさんとのLT大会で使用したスライドです

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
4,679
On Slideshare
2,705
From Embeds
1,974
Number of Embeds
5

Actions

Shares
Downloads
9
Comments
0
Likes
2

Embeds 1,974

http://blog.livedoor.jp 1,499
url_unknown 468
http://webcache.googleusercontent.com 4
http://www.slideshare.net 2
http://www.hanrss.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. class User < ActiveRecord::Base  attr_accessor :name, :age has_many :accountsend
  • 2. ( ω ´)
  • 3. _cond = []File.open(data.csv){|f|  f.each_line do |line|    line.chomp!    id, name, age = line.split(/,/)    _cond << %Q!("#{name}", #{age})! if _cond.size > 1000 # execute insert end  end}
  • 4. parse data.csv do |id, name, age|  format [name, age]end
  • 5. def parse(filepath, separater=,)  if block_given?    File.open(filepath){|f|      f.each_line do |line|        line.chomp!        yield line.split(/#{separater}/)      end    }  else    raise "no block"  end  finalizeend
  • 6. self.includedclass_evalinstance_variable_setdefine_method