Sha256: b458b10d90bfdfda5cde88576bca97ce76c16f2992d27bd91c6c4cb1ad0d6dcd

Contents?: true

Size: 898 Bytes

Versions: 11

Compression:

Stored size: 898 Bytes

Contents

module  Chamber
module  Filters
class   BooleanConversionFilter

  def initialize(options = {})
    self.data = options.fetch(:data).dup
  end

  def self.execute(options = {})
    self.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
        break if value.nil?

        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

11 entries across 11 versions & 1 rubygems

Version Path
chamber-2.2.1 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.2.0 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.1.9 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.1.8 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.1.7 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.1.6 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.1.3 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.1.2 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.1.1 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.1.0 lib/chamber/filters/boolean_conversion_filter.rb
chamber-2.0.0 lib/chamber/filters/boolean_conversion_filter.rb