Skip to content

Commit

Permalink
Money::Currency#to_currency to ease tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
eloyesp committed Jun 2, 2011
1 parent 08e2620 commit a52c3f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/money/currency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ def to_s
id.to_s.upcase
end

# Conversation to +self+.
#
# @return [self]
def to_currency
self
end

# Returns a human readable representation.
#
# @return [String]
Expand Down
5 changes: 5 additions & 0 deletions spec/currency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
Money::Currency.new(:eur).to_s.should == "EUR"
end

specify "#to_currency" do
usd = Money::Currency.new(:usd)
usd.to_currency.should == usd
end

specify "#inspect" do
Money::Currency.new(:usd).inspect.should ==
%Q{#<Money::Currency id: usd, priority: 1, symbol_first: true, thousands_separator: ,, html_entity: $, decimal_mark: ., name: United States Dollar, symbol: $, subunit_to_unit: 100, iso_code: USD, subunit: Cent>}
Expand Down

0 comments on commit a52c3f7

Please sign in to comment.