Sha256: f75ad3a3ab8f45f4fb896a818b1a13ffeb51c4de2c16350082360d7a2f0ebdcb

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

# typed: false
# frozen_string_literal: true

module Workato
  module Extension
    module Object
      # rubocop:disable Naming/PredicateName
      def is_true?(null_true: false)
        if is_a?(::String)
          return true if (self =~ (/\A(true|t|yes|y|1)\Z/i)).present?
          return false if (self =~ (/\A(false|f|no|n|0)\Z/i)).present?
          raise "Can't convert empty string to boolean" if blank?

          raise "Can't convert string value #{self} to boolean"
        elsif is_a?(::Integer)
          return true if self == 1
          return false if zero?

          raise "Can't convert number value #{self} to boolean"
        elsif is_a?(::TrueClass)
          true
        elsif is_a?(::FalseClass)
          false
        elsif is_a?(::NilClass)
          null_true == true
        else
          raise "Can't convert type #{self.class.name} to boolean"
        end
      end

      def is_not_true?(null_not_true: true)
        !is_true?(null_true: !null_not_true)
      end
      # rubocop:enable Naming/PredicateName
    end
  end
end

Object.include(Workato::Extension::Object)

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
workato-connector-sdk-1.3.13 lib/workato/extension/object.rb
workato-connector-sdk-1.3.12 lib/workato/extension/object.rb
workato-connector-sdk-1.3.11 lib/workato/extension/object.rb
workato-connector-sdk-1.3.10 lib/workato/extension/object.rb
workato-connector-sdk-1.3.9 lib/workato/extension/object.rb
workato-connector-sdk-1.3.8 lib/workato/extension/object.rb
workato-connector-sdk-1.3.7 lib/workato/extension/object.rb
workato-connector-sdk-1.3.6 lib/workato/extension/object.rb
workato-connector-sdk-1.3.5 lib/workato/extension/object.rb
workato-connector-sdk-1.3.4 lib/workato/extension/object.rb
workato-connector-sdk-1.3.3 lib/workato/extension/object.rb
workato-connector-sdk-1.3.2 lib/workato/extension/object.rb
workato-connector-sdk-1.3.1 lib/workato/extension/object.rb
workato-connector-sdk-1.3.0 lib/workato/extension/object.rb
workato-connector-sdk-1.2.0 lib/workato/extension/object.rb
workato-connector-sdk-1.0.3 lib/workato/extension/object.rb
workato-connector-sdk-1.1.0 lib/workato/extension/object.rb
workato-connector-sdk-1.0.2 lib/workato/extension/object.rb