lib/chord.rb in chord-0.0.9 vs lib/chord.rb in chord-0.0.10
- old
+ new
@@ -115,11 +115,11 @@
def http_options
self.class.http_options
end
attr_reader :id
- attr_accessor :attributes
+ attr_reader :attributes
def initialize(id, attributes = {})
@id = id
@attributes = attributes
end
@@ -129,22 +129,22 @@
http_options.merge(body: new_attributes.to_json)
).parsed_response
if response.include?('error')
raise APIError, "Chord API error (status #{response['status']}): #{response['error']}"
else
- self.attributes = response
+ @attributes = response
end
end
def delete
self.class.delete(base_url + "#{base_path}/#{id}", http_options).parsed_response
end
# fetch all attributes, but don't overwrite existing ones,
# in case changes have been made
def expand!
- self.attributes = self.class.send(:fetch_attributes, id)
+ @attributes = self.class.send(:fetch_attributes, id)
end
def method_missing(method, *args, &block)
if attributes.include?(method.to_s)
attributes[method.to_s]
@@ -189,9 +189,13 @@
'orders'
end
def self.id_attribute
'number'
+ end
+
+ def complete?
+ state == 'complete'
end
def user
@user ||= Chord::User.find(attributes['user_id'])
end