<<EOS
Field declaration is handled by method_missing(), that means the
declaration must be a valid Ruby method call.
Remember that Ruby has a parser feature that you can omit braces if
the last argument of a method call is a Hash. Rails and Hobo use
that feature for "named options".
EOS
def enum_string(*args)
"type enum_string #{args.inspect}"
end
def decl(type, *args)
puts "@@@ decl(): type = #{type}"
options = args.extract_options!
args.each_with_index { |val, i| puts " args[#{i}] = #{val.inspect}" }
options.each { |key, val| puts " options[#{key.inspect}] = #{val.inspect}" }
end
# decl :decimal, :scale => 1, :precision => 3, :required # 1. syntax error,
unexpected '\n', expecting tASSOC
decl :decimal, { :scale => 1, :precision => 3 }, :required # 2. no syntax
error, but won't work as expected
decl :decimal, :required, { :scale => 1, :precision => 3 } # 3. works
decl :decimal, :required, :scale => 1, :precision => 3 # 4. works, same as
3.
decl enum_string(:first, :second, :third), :required, {} # 5. works
decl enum_string(:first, :second, :third), :required # 6. works, same as
5.
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.