Sha256: a73786253bceb4219d962d0e607396d01b2073f44cff1be0786cafacc6779817

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

require 'normalizy/filters'

module Normalizy
  class Config
    attr_accessor :default_filters
    attr_reader :filters, :normalizy_aliases, :normalizy_raws

    def add(name, value, raw: false)
      @filters[name] = value

      @normalizy_raws << name if raw

      self
    end

    def alias(name, to, raw: false)
      @normalizy_aliases[name] = to
      @normalizy_raws << name if raw

      self
    end

    def initialize
      @default_filters   = {}
      @normalizy_aliases = {}
      @normalizy_raws    = %i[date money number percent]

      @filters = {
        date:    Normalizy::Filters::Date,
        money:   Normalizy::Filters::Money,
        number:  Normalizy::Filters::Number,
        percent: Normalizy::Filters::Percent,
        strip:   Normalizy::Filters::Strip
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
normalizy-0.2.0 lib/normalizy/config.rb