lib/opentransact/asset.rb in opentransact-0.1.1 vs lib/opentransact/asset.rb in opentransact-0.1.2
- old
+ new
@@ -27,18 +27,27 @@
def transfer(amount,to,memo=nil)
client.post(transaction_url,{:amount=>amount,:to=>to,:memo=>memo}) if client
end
def name
- @options["name"]
+ @name ||= @options["name"] || info["name"]
end
def balance
- @options["balance"]
+ @balance ||= @options["balance"] || info["balance"]
end
+ def available_balance
+ @balance ||= @options["available_balance"] || info["available_balance"]
+ end
+
def [](key)
@options[key] if @options
+ end
+
+ # Load meta data about asset from server
+ def info
+ @info ||= client.try(:get, transaction_url)||{}
end
protected
\ No newline at end of file