lib/chord.rb in chord-0.0.7 vs lib/chord.rb in chord-0.0.8

- old
+ new

@@ -135,12 +135,11 @@ end # fetch all attributes, but don't overwrite existing ones, # in case changes have been made def expand! - all_attributes = self.class.send(:fetch_attributes, id) - @attributes = all_attributes.merge(@attributes) + self.attributes = self.class.send(:fetch_attributes, id) end def method_missing(method, *args, &block) if attributes.include?(method.to_s) attributes[method.to_s] @@ -151,40 +150,18 @@ end class User < Base - # - # For avoiding API calls. - # - def self.all_by_id - unless @all_by_id - @all_by_id = {} - all.each do |u| - @all_by_id[u.id] = u - end - end - @all_by_id - end - - # - # For mapping users on our old site to Chord. - # - def self.all_by_email - unless @all_by_email - @all_by_email = {} - all.each do |u| - @all_by_email[u.email] = u - end - end - @all_by_email - end - def self.base_path 'users' end + def orders + Order.where('q[user_id_eq]' => id) + end + def add_role(role_id) self.class.put(base_url + "roles/#{role_id}/add/#{id}", http_options).parsed_response end def remove_role(role_id) @@ -265,9 +242,16 @@ class Product < Base def self.base_path 'products' + end + end + + class Variant < Base + + def self.base_path + 'variants' end end class ConfigurationError < StandardError end