Method: CommonLib::Object#to_boolean

Defined in:
lib/common_lib/ruby/object.rb

#to_booleanObject

# originally from ActiveSupport::Callbacks::Callback needs modified to actually work the way I’d like needs tests x(:some_method) x(Proc.new(.…)) x(lambda…) # def evaluate_method(method, *args, &block) def evaluate_method(method, *args, &block) case method when Symbol I don’t quite understand the shift (it fails) object = args.shift object.send(method, *args, &block) send(method, *args, &block) when String eval(method, args.first.instance_eval { binding }) when Proc, Method fails method.call(*args, &block) else if method.respond_to?(kind) method.send(kind, *args, &block) else raise ArgumentError, “Callbacks must be a symbol denoting the method to call, a string to be evaluated, ” + “a block to be invoked, or an object responding to the callback method.” end end end alias_method :x, :evaluate_method



34
35
36
37
38
# File 'lib/common_lib/ruby/object.rb', line 34

def to_boolean
#		return [true, 'true', 1, '1', 't'].include?(
	return ![nil, false, 'false', 0, '0', 'f'].include?(
		( self.is_a?(String) ) ? self.downcase : self )
end