Sha256: fa047faf958494da869c97eabcd89d951941a4fbd8b76605428878d02351a52d

Contents?: true

Size: 762 Bytes

Versions: 5

Compression:

Stored size: 762 Bytes

Contents

require "active_support/core_ext/module/aliasing.rb"
require "active_support/core_ext/hash/reverse_merge.rb"

class Money

  def format_with_settings(*rules)
    rules = normalize_formatting_rules(rules)

    # Apply global defaults for money only for non-nil values
    defaults = {
      no_cents_if_whole: MoneyRails::Configuration.no_cents_if_whole,
      symbol: MoneyRails::Configuration.symbol,
      sign_before_symbol: MoneyRails::Configuration.sign_before_symbol
    }.reject { |k,v| v.nil? }

    rules.reverse_merge!(defaults)

    unless MoneyRails::Configuration.default_format.nil?
      rules.reverse_merge!(MoneyRails::Configuration.default_format)
    end

    format_without_settings(rules)
  end

  alias_method_chain :format, :settings

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
money-rails-1.4.1 lib/money-rails/money.rb
money-rails-1.4.0 lib/money-rails/money.rb
money-rails-1.3.0 lib/money-rails/money.rb
money-rails-1.2.0 lib/money-rails/money.rb
money-rails-1.1.0 lib/money-rails/money.rb