From 26e5f517e02341552bcc0d2bf37abf547d8da5df Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 11 Jun 2013 12:45:18 +0200 Subject: [PATCH] added begin rescue arround model init assignment --- lib/bitstamp/model.rb | 6 +++++- lib/bitstamp/ticker.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/bitstamp/model.rb b/lib/bitstamp/model.rb index 2df1a86..406b20b 100644 --- a/lib/bitstamp/model.rb +++ b/lib/bitstamp/model.rb @@ -15,7 +15,11 @@ def initialize(attributes = {}) # Set the attributes based on the given hash def attributes=(attributes = {}) attributes.each do |name, value| - send("#{name}=", value) + begin + send("#{name}=", value) + rescue NoMethodError => e + puts "Unable to assign #{name}. No such method." + end end end diff --git a/lib/bitstamp/ticker.rb b/lib/bitstamp/ticker.rb index e163b86..3980080 100644 --- a/lib/bitstamp/ticker.rb +++ b/lib/bitstamp/ticker.rb @@ -1,6 +1,6 @@ module Bitstamp class Ticker < Bitstamp::Model - attr_accessor :last, :high, :low, :volume, :bid, :ask + attr_accessor :last, :high, :low, :volume, :bid, :ask, :timestamp def self.from_api Bitstamp::Helper.parse_object!(Bitstamp::Net.get('/ticker').body_str, self)