Class: Rhoconnect::App

Inherits:
Model
  • Object
show all
Defined in:
lib/rhoconnect/app.rb

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

Constructor Details

This class inherits a constructor from Rhoconnect::Model

Instance Attribute Details

#delegateObject (readonly)

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(, password)
  self.delegate ? self.delegate.ans_authenticate(, 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(, password, session)
  if Rhoconnect.appserver
    auth_result = DynamicAdapter.authenticate(,password)
  elsif self.delegate
    auth_result = self.delegate.authenticate(, password, session) 
  end
  
  if auth_result
     = auth_result if auth_result.is_a? String
    user = User.load() if User.is_exist?()
    if not user
      user = User.create(:login => )
      users << user.id
    end
    return user
  end
end

#can_ans_authenticate?Boolean

Returns:

  • (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

Returns:

  • (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

#deleteObject



52
53
54
55
# File 'lib/rhoconnect/app.rb', line 52

def delete
  @@sources = []
  super
end

#delete_sourcesObject



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

#sourcesObject



77
78
79
80
81
# File 'lib/rhoconnect/app.rb', line 77

def sources
  @@sources.uniq!
  # Sort sources array by priority
  @@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