Class: Gera::RateSource
Constant Summary
collapse
- RateNotFound =
Class.new StandardError
Class Method Summary
collapse
Instance Method Summary
collapse
generate_pairs_from_currencies
Class Method Details
.available_pairs ⇒ Object
36
37
38
|
# File 'app/models/gera/rate_source.rb', line 36
def self.available_pairs
generate_pairs_from_currencies supported_currencies
end
|
.get! ⇒ Object
40
41
42
|
# File 'app/models/gera/rate_source.rb', line 40
def self.get!
where(type: name).take!
end
|
.supported_currencies ⇒ Object
32
33
34
|
# File 'app/models/gera/rate_source.rb', line 32
def self.supported_currencies
raise 'not implemented'
end
|
Instance Method Details
#actual_rates ⇒ Object
56
57
58
|
# File 'app/models/gera/rate_source.rb', line 56
def actual_rates
external_rates.where(snapshot_id: actual_snapshot_id)
end
|
#find_rate_by_currency_pair(pair) ⇒ Object
48
49
50
|
# File 'app/models/gera/rate_source.rb', line 48
def find_rate_by_currency_pair(pair)
actual_rates.find_by_currency_pair pair
end
|
#find_rate_by_currency_pair!(pair) ⇒ Object
44
45
46
|
# File 'app/models/gera/rate_source.rb', line 44
def find_rate_by_currency_pair!(pair)
find_rate_by_currency_pair(pair) || raise(RateNotFound, pair)
end
|
#is_currency_supported?(cur) ⇒ Boolean
64
65
66
67
|
# File 'app/models/gera/rate_source.rb', line 64
def is_currency_supported?(cur)
cur = Money::Currency.find cur unless cur.is_a? Money::Currency
supported_currencies.include? cur
end
|
#to_s ⇒ Object
52
53
54
|
# File 'app/models/gera/rate_source.rb', line 52
def to_s
name
end
|