Class: Videojuicer::User
- Includes:
- Exceptions, Resource
- Defined in:
- lib/videojuicer/user.rb
Instance Attribute Summary collapse
-
#roles ⇒ Object
Manage virtual attributes that are not sent back to the API.
Attributes included from Configurable
Class Method Summary collapse
-
.authenticate(login, password) ⇒ Object
Authenticates the given login and password and returns a user if the details are correct.
Instance Method Summary collapse
Methods included from Resource
#destroy, #errors, #errors=, #errors_on, included, #new_record?, #reload, #save, #update_attributes, #valid?, #validate_response
Methods included from Resource::Relationships::BelongsTo
Methods included from Resource::PropertyRegistry
#attr_get, #attr_set, #attributes, #attributes=, #coerce_value, #default_attributes, included, inherited, #initialize, #returnable_attributes
Methods included from Resource::Inferrable
Methods included from OAuth::ProxyFactory
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
#roles ⇒ Object
Manage virtual attributes that are not sent back to the API
29 30 31 |
# File 'lib/videojuicer/user.rb', line 29 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.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/videojuicer/user.rb', line 16 def self.authenticate(login, password) proxy = Videojuicer::OAuth::RequestProxy.new begin jobj = JSON.parse(proxy.get("/users/authenticate.json", :login=>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
34 35 36 |
# File 'lib/videojuicer/user.rb', line 34 def add_role(*symbols) symbols.each {|r| proxy_for(config).post(resource_path(:add_role), :role=>r) } end |
#has_role?(symbol) ⇒ Boolean
30 31 32 |
# File 'lib/videojuicer/user.rb', line 30 def has_role?(symbol) roles.include?(symbol.to_s) end |
#remove_role(*symbols) ⇒ Object
38 39 40 |
# File 'lib/videojuicer/user.rb', line 38 def remove_role(*symbols) symbols.each {|r| proxy_for(config).post(resource_path(:remove_role), :role=>r) } end |