Method: Terraspace::App::CallableOption#object
- Defined in:
- lib/terraspace/app/callable_option.rb
#object ⇒ Object
Returns either an Array or nil
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/terraspace/app/callable_option.rb', line 28 def object case @config_value when nil return nil when Array return @config_value when -> (c) { c.respond_to?(:public_instance_methods) && c.public_instance_methods.include?(:call) } object= @config_value.new when -> (c) { c.respond_to?(:call) } object = @config_value else raise "Invalid option for #{@config_name}" end if object result = @passed_args.empty? ? object.call : object.call(*@passed_args) unless result.is_a?(Array) || result.is_a?(NilClass) = "ERROR: The #{@config_name} needs to return an Array or nil" logger.info .color(:yellow) logger.info <<~EOL The #{@config_name} when assigned a class, object, or proc must implement the call method and return an Array or nil. The current return value is a #{result.class} EOL raise end end result end |