Sha256: fa75c964024917fc2e6e4557c4d78b0035f4c565a01e538767d45a16dd0d028c
Contents?: true
Size: 815 Bytes
Versions: 2
Compression:
Stored size: 815 Bytes
Contents
# frozen_string_literal: true module Lite module Command module Utils module_function def try(object, method_name, *args, include_private: true) return unless object.respond_to?(method_name, include_private) object.send(method_name, *args) end def call(object, argument) if argument.is_a?(Symbol) || argument.is_a?(String) object.send(argument) elsif argument.is_a?(Proc) object.instance_eval(&argument) else argument end end def evaluate(object, options = {}) if options[:if] call(object, options[:if]) elsif options[:unless] !call(object, options[:unless]) else options.fetch(:default, true) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lite-command-3.0.1 | lib/lite/command/utils.rb |
lite-command-3.0.0 | lib/lite/command/utils.rb |