Skip to content

Commit

Permalink
added begin rescue arround model init assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
stygeo committed Jun 11, 2013
1 parent 8a113fe commit 26e5f51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/bitstamp/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/bitstamp/ticker.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 26e5f51

Please sign in to comment.