lib/mothership/inputs.rb in mothership-0.1.0 vs lib/mothership/inputs.rb in mothership-0.1.1

- old
+ new

@@ -23,26 +23,26 @@ @given[name] end end def merge(inputs) - self.class.new(@command, @context, @inputs.merge(inputs), @given) + self.class.new(@command, @context, @inputs.merge(inputs), @given, @global) end def merge_given(inputs) - self.class.new(@command, @context, @inputs, @given.merge(inputs)) + self.class.new(@command, @context, @inputs, @given.merge(inputs), @global) end def without(*names) given = @given.dup inputs = @inputs.dup names.each do |n| given.delete(n) inputs.delete(n) end - self.class.new(@command, @context, given, inputs) + self.class.new(@command, @context, given, inputs, @global) end def [](name, *args) get(name, @context, *args) end @@ -55,19 +55,16 @@ # 5. global # 6. global, singular def get(name, context, *args) return @inputs[name] if @inputs.key?(name) - if meta = @command.inputs[name] + if @command && meta = @command.inputs[name] # special case so #invoke can be called with singular-named inputs singular = meta[:singular] return @inputs[name] = [@inputs[singular]] if @inputs.key?(singular) found, val = find_in(@given, name, meta, context, *args) - end - - # if not found locally and the default is nil, search globally - if !found && val.nil? && meta = Mothership.global_option(name) + elsif meta = Mothership.global_option(name) found, val = find_in(@global, name, meta, context, *args) end return val if not found