Sha256: 9c9b55df891ed4c511c274f5ce779261bfac98a01dab4d31014725b8d3e5139d

Contents?: true

Size: 880 Bytes

Versions: 23

Compression:

Stored size: 880 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Utils
    module Bool
      ##
      # Converts objects to boolean.
      # Implementation is very basic just to serve the need of this library.
      # More comprehensive solution can be found in Rails, wannabe_bool, etc:
      # - https://api.rubyonrails.org/classes/ActiveModel/Type/Boolean.html
      # - https://github.com/prodis/wannabe_bool
      #
      class ToBool < Support::Command
        ##
        # @!attribute [r] object
        #   @return [Object] Can be any type.
        #
        attr_reader :object

        ##
        # @param object [Object] Can be any type.
        # @return [void]
        #
        def initialize(object)
          @object = object
        end

        ##
        # @return [Boolean]
        #
        def call
          !!object
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
convenient_service-0.2.1 lib/convenient_service/utils/bool/to_bool.rb
convenient_service-0.2.0 lib/convenient_service/utils/bool/to_bool.rb
convenient_service-0.1.0 lib/convenient_service/utils/bool/to_bool.rb