Sha256: 491a9ed0837ee1e19890c17d5cfd6d8c5ffc37d7c0a3939df0d30b2a20455c80

Contents?: true

Size: 669 Bytes

Versions: 5

Compression:

Stored size: 669 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
    # TODO: Add here more setting options
    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)

    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.0.0 lib/money-rails/money.rb
money-rails-0.12.0 lib/money-rails/money.rb
money-rails-0.11.0 lib/money-rails/money.rb
money-rails-0.10.0 lib/money-rails/money.rb
money-rails-0.9.0 lib/money-rails/money.rb