Sha256: 8d6d2f9c7191ab4a8328437678abf5df93cb6376e8a9784b5ee15650eecd1c2a

Contents?: true

Size: 315 Bytes

Versions: 1

Compression:

Stored size: 315 Bytes

Contents

module Bodega
  module Monetize
    def monetize(attribute)
      class_eval <<-monetize
        def #{attribute}=(value)
          self.#{attribute}_in_cents = (value.to_f * 100).to_i
        end

        def #{attribute}
          (#{attribute}_in_cents || 0) / 100.0
        end
      monetize
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bodega-0.2.0 lib/bodega/monetize.rb