Class: Rhoconnect::App
Constant Summary
collapse
- @@sources =
[]
Instance Attribute Summary collapse
Attributes inherited from Model
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Model
_field_key, _prefix, class_prefix, #decrement!, field, #field_key, fields, #increment!, #initialize, is_exist?, list, load, marshal_class_name, #next_id, populate_attributes, #redis, redis, set, #to_array, validates_presence_of
Instance Attribute Details
#delegate ⇒ Object
Returns the value of attribute delegate.
5
6
7
|
# File 'lib/rhoconnect/app.rb', line 5
def delegate
@delegate
end
|
Class Method Details
.create(fields = {}) ⇒ Object
11
12
13
14
|
# File 'lib/rhoconnect/app.rb', line 11
def create(fields={})
fields[:id] = fields[:name]
super(fields)
end
|
Instance Method Details
#ans_authenticate(login, password) ⇒ Object
44
45
46
|
# File 'lib/rhoconnect/app.rb', line 44
def ans_authenticate(login, password)
self.delegate ? self.delegate.ans_authenticate(login, password) : false
end
|
#authenticate(login, password, session) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rhoconnect/app.rb', line 26
def authenticate(login, password, session)
if Rhoconnect.appserver
auth_result = DynamicAdapter.authenticate(login,password)
elsif self.delegate
auth_result = self.delegate.authenticate(login, password, session)
end
if auth_result
login = auth_result if auth_result.is_a? String
user = User.load(login) if User.is_exist?(login)
if not user
user = User.create(:login => login)
users << user.id
end
return user
end
end
|
#can_ans_authenticate? ⇒ Boolean
21
22
23
|
# File 'lib/rhoconnect/app.rb', line 21
def can_ans_authenticate?
self.delegate && self.delegate.singleton_methods.map(&:to_sym).include?(:ans_authenticate)
end
|
#can_authenticate? ⇒ Boolean
17
18
19
|
# File 'lib/rhoconnect/app.rb', line 17
def can_authenticate?
self.delegate && self.delegate.singleton_methods.map(&:to_sym).include?(:authenticate)
end
|
#delete ⇒ Object
52
53
54
55
|
# File 'lib/rhoconnect/app.rb', line 52
def delete
@@sources = []
super
end
|
#delete_sources ⇒ Object
57
58
59
|
# File 'lib/rhoconnect/app.rb', line 57
def delete_sources
@@sources = []
end
|
#partition_sources(partition, user_id) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/rhoconnect/app.rb', line 61
def partition_sources(partition,user_id)
names = []
@@sources.each do |source|
s = Source.load(source,{:app_id => self.name,
:user_id => user_id})
if s.partition == partition
names << s.name
end
end
names
end
|
#sources ⇒ Object
77
78
79
80
81
|
# File 'lib/rhoconnect/app.rb', line 77
def sources
@@sources.uniq!
@@sources = @@sources.sort_by { |s| Source.load(s, {:app_id => self.name, :user_id => '*'}).priority }
end
|
#store_blob(obj, field_name, blob) ⇒ Object
73
74
75
|
# File 'lib/rhoconnect/app.rb', line 73
def store_blob(obj,field_name,blob)
self.delegate.send :store_blob, obj,field_name,blob
end
|