Class: Videojuicer::User

Inherits:
Object show all
Includes:
Exceptions, Resource
Defined in:
lib/videojuicer/user.rb

Instance Attribute Summary collapse

Attributes included from Configurable

#local_config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

#destroy, #errors, #errors=, #errors_on, included, #new_record?, #reload, #save, #to_json, #update_attributes, #valid?, #validate_committed_response, #validate_response

Methods included from Resource::Relationships::BelongsTo

included

Methods included from Resource::PropertyRegistry

#attr_clean!, #attr_dirty!, #attr_dirty?, #attr_get, #attr_set, #attributes, #attributes=, #clean_dirty_attributes!, #coerce_value, #default_attributes, #dirty_attribute_keys, #dirty_attributes, included, inherited, #initialize, #invalid_attributes, #returnable_attributes, #set_default_attributes

Methods included from Resource::Inferrable

included

Methods included from OAuth::ProxyFactory

#proxy_for

Methods included from Configurable

#api_version, #config, #configure!, #consumer_key, #consumer_secret, #host, #port, #protocol, #scope, #seed_name, #token, #token_secret, #user_id

Instance Attribute Details

#rolesObject

Manage virtual attributes that are not sent back to the API



30
31
32
# File 'lib/videojuicer/user.rb', line 30

def roles
  @roles
end

Class Method Details

.authenticate(login, password) ⇒ Object

Authenticates the given login and password and returns a user if the details are correct. Requires a Master token.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/videojuicer/user.rb', line 17

def self.authenticate(, password)
  proxy = Videojuicer::OAuth::RequestProxy.new
  begin
    jobj = JSON.parse(proxy.get("/users/authenticate.json", :login=>, :password=>password).body)
    o = new(:id=>jobj["id"])
    o.reload
    return o
  rescue NoResource =>e
    return nil
  end
end

Instance Method Details

#add_role(*symbols) ⇒ Object



35
36
37
# File 'lib/videojuicer/user.rb', line 35

def add_role(*symbols)
  symbols.each {|r| proxy_for(config).post(resource_path(:add_role), :role=>r) }
end

#has_role?(symbol) ⇒ Boolean

Returns:



31
32
33
# File 'lib/videojuicer/user.rb', line 31

def has_role?(symbol)
  roles.include?(symbol.to_s)
end

#remove_role(*symbols) ⇒ Object



39
40
41
# File 'lib/videojuicer/user.rb', line 39

def remove_role(*symbols)
  symbols.each {|r| proxy_for(config).post(resource_path(:remove_role), :role=>r) }
end