156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/appkernel/function.rb', line 156
def ingest(o)
@options[o.name] = o
@indexed[o.index] = o if o.index
@required << o.name if o.required?
@defaults << o.name if o.default?
if o.default? && o.type
if Enumerable === o.type
if not o.type.detect {|t| o.default.kind_of?(t)}
raise IllegalOptionError, "default value #{o.default.inspect} for option '#{o.name}' is not in #{o.type.inspect}"
end
elsif not o.default.kind_of?(o.type)
raise IllegalOptionError, "default value #{o.default.inspect} for option '#{o.name}' is not a #{o.type}"
end
end
if o.greedy?
raise IllegalOptionError, "a function may not have more than one greedy option. has (#{@greedy.name}, #{o.name})" if @greedy
@greedy = o
end
raise IllegalOptionError, "a greedy option may not have an index" if o.greedy? && o.index
end
|