Sha256: 8529ed07a09c76562234e9cc7eb28a9c6e6e3dad29566aa15e7a3c8d301ebecb

Contents?: true

Size: 768 Bytes

Versions: 5

Compression:

Stored size: 768 Bytes

Contents

require 'administrate/field/text'
require 'administrate/engine'

module Administrate
  module Field
    class Money < Administrate::Field::Text
      class Engine < ::Rails::Engine
        Administrate::Engine.add_javascript 'administrate-field-money/application'
      end

      def to_s
        money.format(symbol: symbol, separator: separator, delimiter: delimiter)
      end

      def money
        @money ||= ::Money.new(data, code)
      end

      def code
        options.fetch(:code, 'USD')
      end

      def symbol
        options.fetch(:symbol, money.symbol)
      end

      def delimiter
        options.fetch(:delimiter, money.delimiter)
      end

      def separator
        options.fetch(:separator, money.separator)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
administrate-field-money-0.0.6 lib/administrate/field/money.rb
administrate-field-money-0.0.5 lib/administrate/field/money.rb
administrate-field-money-0.0.4 lib/administrate/field/money.rb
administrate-field-money-0.0.3 lib/administrate/field/money.rb
administrate-field-money-0.0.2 lib/administrate/field/money.rb