Sha256: bd21cb13cb92a5b9fb8891874eae36e0c8bddc9c7753a70e7422c0a58f0d84bc

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

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.8.0 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.7.1 lib/chamber/filters/boolean_conversion_filter.rb