Module: ODDB::Util::Yus

Defined in:
lib/oddb/util/yus.rb

Class Method Summary collapse

Class Method Details

.create_user(email, pass = nil) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/oddb/util/yus.rb', line 10

def Yus.create_user(email, pass=nil)
  Yus.server.autosession(ODDB.config.auth_domain) { |session|
    session.create_entity(email, pass)
  }
  # if there is a password, we can log in
  ODDB.server.(email, pass) if(pass)
end

.get_preference(name, key) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/oddb/util/yus.rb', line 17

def Yus.get_preference(name, key)
  Yus.server.autosession(ODDB.config.auth_domain) { |session|
    session.get_entity_preference(name, key)
  }
rescue ::Yus::YusError
  nil # return nil
end

.get_preferences(name, *keys) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/oddb/util/yus.rb', line 24

def Yus.get_preferences(name, *keys)
  Yus.server.autosession(ODDB.config.auth_domain) { |session|
    session.get_entity_preferences(name, keys.flatten)
  }
rescue ::Yus::YusError
  {} # return an empty hash
end

.grant(name, key, item, expires = nil) ⇒ Object



31
32
33
34
35
# File 'lib/oddb/util/yus.rb', line 31

def Yus.grant(name, key, item, expires=nil)
  Yus.server.autosession(ODDB.config.auth_domain) { |session|
    session.grant(name, key, item, expires)
  }
end

.serverObject



36
37
38
# File 'lib/oddb/util/yus.rb', line 36

def Yus.server
  DRb::DRbObject.new(nil, ODDB.config.auth_server)
end

.set_preference(name, key, value, domain = ODDB.config.auth_domain) ⇒ Object



39
40
41
42
43
# File 'lib/oddb/util/yus.rb', line 39

def Yus.set_preference(name, key, value, domain=ODDB.config.auth_domain)
  Yus.server.autosession(ODDB.config.auth_domain) { |session|
    session.set_entity_preference(name, key, value, domain)
  }
end