ã®ããã«æ¸ãã®ããDSLçã«ã¡ãã£ã¨ãã£ãããããã§ãã ããã§ã以ä¸ã®ãããªãã®ãããã°ã¡ãã£ã¨å¥éºã«æ¸ãã¾ãã 1 class Symbol 2 def method_missing(method, *args, &block) 3 if args.empty? && block.nil? 4 [self, method].join(':').intern 5 else 6 super 7 end 8 end 9 end 10 11 >> :foo #=> :foo 12 >> :foo.bar #=> :"foo:bar" 13 >> :foo.bar.baz #=> :"foo:bar:baz"
æ¶è²»è éèã®ã«ã¼ããã¼ã³ã®ç³ãè¾¼ã¿æ¸é¡ã«åãæ¸ãã¦ç³ãè¾¼ãã ã審æ»ã«éãã¾ãããä»ç¾å¨ãã®ã«ã¼ããã¼ã³ã¯æå¹ã«ä½¿ã£ã¦ãã¾ãããåãã¤ãã¦ãããã¨ããããã¨ä½ãåé¡ãçºçãã¾ããï¼ã¡ãªã¿ã«ä»åã¯ä»ç¤¾ããã®åå ¥éé¡ãå°ãå°ãªãã«ç³åãã¾ãããããããã£ããã©ã®ãããªãã¨ã«ãªãã®ãæãã¦ã»ããã§ãã 審æ»æ¸é¡ã«åãè¨å ¥ãã¦ãã¦ããåããã¦ãããªãåé¡ãªãï¼ ã«ã¼ããã¼ã³ã®å¯©æ»ã§åãè¨å ¥ãããã¨ã¯ãã¾ã好ã¾ãããã¨ã§ã¯ãªãã§ãããã§ããããã§åããã¦ããã®ã§ããã°ããã»ã©å¤§ããªåé¡ã¯ãªãã§ããããã¨ãè¨ãã®ããããåãè¨å ¥ãã¦ãæ¶è²»è éèæ¥è ã§ã¯èª¿ã¹ãã°ã»ã¨ãã©ã®æ å ±ã確èªã§ãã¾ããä»åã¯ä»ç¤¾åå ¥ãå°ãªãè¨å ¥ããã¨ã®ãã¨ã§ãããçµå±ãã®åã¯ãã¬ã¦ãã¦ããã®ä¸ã§ãéã貸ãã¦ããããã¨æã£ã¦ããã§ãããã æ¶è²»è éèæ¥è ã¯ç³è¾¼æ¸ã«è¨å ¥ãããå 容ã¯æ®ã©ã®ãã®ã確èªã§ãã¾ããä½æãååã¯èº«å証ææ¸ããã®ã³
çµæ§é·ããªããã§ï¼ãã°ã®ç¶ããåå²ï¼ rake taskãè¦ã¦ã¿ã ã²ã¨ã¾ãæµã edge railsã§è¦ã¦ã¿ããã¨ã«ï¼ ã¨ããããdiffãã¨ã£ã¦ããï¼ % rake -T > ../rake_tasks_2-0-2 % rake rails:freeze:edge % rake -T > ../rake_tasks_edge % diff ../rake_tasks_2-0-2 ../rake_taskes_edge 1c1 < (in /home/rust/program/ruby/gitexample3) --- > (in /home/rust/program/ruby/gitexample) 11a12 > rake db:migrate:down # Runs the "down" for a given migratio... 13a15 > rake db:migrate
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}