Sha256: 91f39d80bee95f540416285377d20210b88b987fcdde17e4e77e1dfc67fec3ab

Contents?: true

Size: 897 Bytes

Versions: 2

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true
module  Chamber
module  Filters
class   BooleanConversionFilter
  def initialize(options = {})
    self.data = options.fetch(:data).dup
  end

  def self.execute(options = {})
    new(options).__send__(:execute)
  end

  protected

  attr_accessor :data

  def execute(settings = data)
    settings.each_pair do |key, value|
      if value.respond_to? :each_pair
        execute(value)
      else
        settings[key] = if value.is_a? String
                          case value
                          when 'false', 'f', 'no'
                            false
                          when 'true', 't', 'yes'
                            true
                          else
                            value
                          end
                        else
                          value
                        end
      end
    end
  end
end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chamber-2.9.1 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.9.0 lib/chamber/filters/boolean_conversion_filter.rb