Class: Chord::User

Inherits:
Base
  • Object
show all
Defined in:
lib/chord.rb

Instance Attribute Summary

Attributes inherited from Base

#attributes, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, #base_path, #base_url, base_url, #delete, #expand!, find, #http_options, http_options, #initialize, #method_missing, #update, where

Constructor Details

This class inherits a constructor from Chord::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chord::Base

Class Method Details

.base_pathObject



160
161
162
# File 'lib/chord.rb', line 160

def self.base_path
  'users'
end

Instance Method Details

#add_role(role_id) ⇒ Object



168
169
170
# File 'lib/chord.rb', line 168

def add_role(role_id)
  self.class.put(base_url + "roles/#{role_id}/add/#{id}", http_options).parsed_response
end

#find_subscription(subscription_id) ⇒ Object



180
181
182
# File 'lib/chord.rb', line 180

def find_subscription(subscription_id)
  self.class.get(base_url + "users/#{id}/subscriptions/#{subscription_id}", http_options).parsed_response
end

#ordersObject



164
165
166
# File 'lib/chord.rb', line 164

def orders
  Order.where('q[user_id_eq]' => id)
end

#remove_role(role_id) ⇒ Object



172
173
174
# File 'lib/chord.rb', line 172

def remove_role(role_id)
  self.class.put(base_url + "roles/#{role_id}/remove/#{id}", http_options).parsed_response
end

#subscriptionsObject



176
177
178
# File 'lib/chord.rb', line 176

def subscriptions
  self.class.get(base_url + "/subscriptions?q[user_id_in]=#{id}", http_options).parsed_response['subscriptions'].map{ |s| Chord::Subscription.new(s['id'], s) }
end