[sequel] sequel里面的小动作

花花公子 2009-04-15
from lib/sequel/core_sql.rb
# If no argument is given, returns a Sequel::SQL::ColumnAll object specifying all
# columns for this table.
# If an argument is given, returns a Sequel::SQL::NumericExpression using the *
# (multiplication) operator with this and the given argument.
# 
#   :table.* # SQL: table.*
#   :column * 2 # SQL: column * 2
class Symbol
  def *(ce=(arg=false;nil))
    return super(ce) unless arg == false
    Sequel::SQL::ColumnAll.new(self);
  end
end


巧妙利用默认值的特性,保证没有参数传入和传入一个参数执行不同的动作。
Global site tag (gtag.js) - Google Analytics