lib/mothership/inputs.rb in mothership-0.0.3 vs lib/mothership/inputs.rb in mothership-0.0.4
- old
+ new
@@ -33,16 +33,24 @@
def [](name, *args)
get(name, @context, *args)
end
def get(name, context, *args)
- return @inputs[name] if @inputs.key?(name) && @inputs[name] != []
-
return @cache[name] if @cache.key? name
meta = @command.inputs[name]
-
return unless meta
+
+ if @inputs.key?(name) && @inputs[name] != []
+ val =
+ if meta[:from_given]
+ @context.instance_exec(@inputs[name], *args, &meta[:from_given])
+ else
+ @inputs[name]
+ end
+
+ return @cache[name] = val
+ end
val =
if meta[:default].respond_to? :to_proc
unless context
raise "no context for input request"