module Rubeetup::Utilities
Provides some miscellaneous methods for mix-ins
Public Instance Methods
blank?(obj)
click to toggle source
@param [Object] obj an object @return [Boolean] whether the object is blank as per Ruby Active Support
# File lib/rubeetup/utilities.rb, line 18 def blank?(obj) obj.nil? || obj == false || obj.empty? || obj =~ /^\s+$/ end
collection_symbolyzer(array)
click to toggle source
Transforms the strings into a possibly nested collection, into symbols @note For speed and simplicity no error checking is performed @param [Array<String, Array…>] array a possibly recursive collection of strings @return [Array<Symbol, Array…>] a possibly recursive collection of Symbols
# File lib/rubeetup/utilities.rb, line 38 def collection_symbolyzer(array) array.map {|elem| elem.is_a?(String) ? elem.to_sym : collection_symbolyzer(elem)} end
present?(obj)
click to toggle source
Determines if the object is not blank (see blank?
)
# File lib/rubeetup/utilities.rb, line 10 def present?(obj) !blank?(obj) end
stringify(options)
click to toggle source
Generates a string of key values to include in URL’s @param [Hash{Symbol=>String}] options holds options for a request @return [String] a sringified representation of a Hash of options
# File lib/rubeetup/utilities.rb, line 27 def stringify(options) return '' unless options.respond_to? :map options.map { |key, val| "#{key}=#{val}" if key && val }.compact.join('&') end