Sha256: ae4decd0f879dff2c5447962d0a26485b8221c6bce697056938c0a775e4a402a
Contents?: true
Size: 1.26 KB
Versions: 23
Compression:
Stored size: 1.26 KB
Contents
module Videojuicer class User include Videojuicer::Resource include Videojuicer::Exceptions property :name, String property :login, String property :email, String property :password, String property :password_confirmation, String property :created_at, DateTime property :updated_at, DateTime property :roles, Array, :writer => :readonly # Authenticates the given login and password and returns # a user if the details are correct. Requires a Master token. 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 # Manage virtual attributes that are not sent back to the API attr_accessor :roles def has_role?(symbol) roles.include?(symbol.to_s) end def add_role(*symbols) symbols.each {|r| proxy_for(config).post(resource_path(:add_role), :role=>r) } end def remove_role(*symbols) symbols.each {|r| proxy_for(config).post(resource_path(:remove_role), :role=>r) } end end end
Version data entries
23 entries across 23 versions & 1 rubygems