Sha256: 059ec7294f40bed543b8e2ba68c9fa542576e3f16424a0c427cefb09c5abba7d

Contents?: true

Size: 654 Bytes

Versions: 13

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require_relative 'base'

module RubyVault
  module Options
    module Values
      class Boolean < Base
        def resolve
          return nil if @value.nil?
          return @value if a_boolean?(@value)
          return true if true_as_string?(@value)

          false
        end

        def render
          resolve.nil? ? nil : resolve.to_s
        end

        private

        def a_boolean?(value)
          value.is_a?(TrueClass) || value.is_a?(FalseClass)
        end

        def true_as_string?(value)
          value.respond_to?(:downcase) && value.downcase == 'true'
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ruby_vault-0.1.0.pre.16 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.15 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.14 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.13 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.12 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.11 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.10 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.9 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.8 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.7 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.6 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.5 lib/ruby_vault/options/values/boolean.rb
ruby_vault-0.1.0.pre.4 lib/ruby_vault/options/values/boolean.rb