Module: Picklive::Currency::ModelMethods

Defined in:
lib/picklive/currency.rb

Overview

It provides scopes for models that have a ‘currency_code` method.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



135
136
137
138
139
140
141
142
# File 'lib/picklive/currency.rb', line 135

def self.included(base)
  if defined?(ActiveRecord::Base) && base.superclass == ActiveRecord::Base
    base.class_eval do
      scope :cash_only,    where(:currency_code => Picklive::Currency.cash_codes)
      scope :virtual_only, where(:currency_code => Picklive::Currency.virtual_codes)
    end
  end
end

Instance Method Details

#amount_in_currencyObject



148
149
150
# File 'lib/picklive/currency.rb', line 148

def amount_in_currency
  currency.new(amount_in_pennies)
end

#currencyObject



144
145
146
# File 'lib/picklive/currency.rb', line 144

def currency
  Picklive::Currency[currency_code]
end