Class: Rhoconnect::App

Inherits:
StoreOrm show all
Defined in:
lib/rhoconnect/app.rb

Constant Summary collapse

@@sources =
[]

Instance Attribute Summary

Attributes inherited from StoreOrm

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StoreOrm

_field_key, _prefix, class_prefix, #decrement!, field, #field_key, fields, #increment!, #initialize, is_exist?, list, load, marshal_class_name, #next_id, populate_attributes, set, #store, store, #to_array, validates_presence_of

Constructor Details

This class inherits a constructor from Rhoconnect::StoreOrm

Class Method Details

.create(fields = {}) ⇒ Object



10
11
12
13
# File 'lib/rhoconnect/app.rb', line 10

def create(fields={})
  fields[:id] = fields[:name]
  super(fields)
end

Instance Method Details

#deleteObject



16
17
18
19
# File 'lib/rhoconnect/app.rb', line 16

def delete
  @@sources = []
  super
end

#delete_sourcesObject



21
22
23
# File 'lib/rhoconnect/app.rb', line 21

def delete_sources
  @@sources = []
end

#partition_sources(partition, user_id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rhoconnect/app.rb', line 25

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



37
38
39
40
41
# File 'lib/rhoconnect/app.rb', line 37

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