Sha256: 297d98c2e57b4dab30f469f5686be7de3f282c2b6c5bd77825afc09974d8d041

Contents?: true

Size: 435 Bytes

Versions: 1

Compression:

Stored size: 435 Bytes

Contents

module Danconia
  module Stores
    class ActiveRecord
      def save_rates rates
        ExchangeRate.transaction do
          rates.each do |pair, rate|
            ExchangeRate.where(pair: pair).first_or_initialize.update rate: rate
          end
        end
      end

      def rates
        Hash[ExchangeRate.all.map { |er| [er.pair, er.rate] }]
      end
    end

    class ExchangeRate < ::ActiveRecord::Base
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danconia-0.2.9 lib/danconia/stores/active_record.rb