Class: MixCloud::User

Inherits:
Hashie::Dash
  • Object
show all
Includes:
HTTParty
Defined in:
lib/mixcloud/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_name, options = {}) ⇒ User

Returns a new instance of User.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/mixcloud/user.rb', line 32

def initialize(user_name, options={})
  @options = options
  @user = self.class.get("/#{user_name}?metadata=1", :query => @options)

  @user['metadata']['connections'].each do |k,v|
    @user['metadata'][k.to_sym] = v
  end
  @user['metadata'].delete('connections')
  
  @user['metadata'].each do |k,v|
    self.class.send(:define_method, "#{k}".downcase) do |options|
      options = options ||= @options                  
      self.class.get("#{self.[k.to_sym]}", :query => @options)          
     end
  end
        
  super @user
end

Instance Attribute Details

#options=(value) ⇒ Object (writeonly)

Sets the attribute options

Parameters:

  • value

    the value to set the attribute options to.



8
9
10
# File 'lib/mixcloud/user.rb', line 8

def options=(value)
  @options = value
end

Class Method Details

.find(user_name, options = {}) ⇒ Object



51
52
53
# File 'lib/mixcloud/user.rb', line 51

def self.find(user_name, options={})
  self.new user_name, options
end