Module: Rig::Account

Defined in:
lib/rig/account.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loadedObject (readonly)

Returns the value of attribute loaded.



5
6
7
# File 'lib/rig/account.rb', line 5

def loaded
  @loaded
end

.nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/rig/account.rb', line 4

def name
  @name
end

Class Method Details

.data(name = get) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rig/account.rb', line 7

def data(name = get)
  if @name != name
    @data = nil
    @loaded = false
    @name = nil
  end

  @data ||= begin
    Rig::Log.debug "loading account"
    a        = Rig::Model::Account.load(name)
    a[:name] = name

    Rig::Log.debug "loading plugins from account"
    Rig::Plugin.load(a[:plugins]) if a[:plugins]

    a
  end
  @name = @data[:name]
  @loaded = true
  @data
end

.getObject



29
30
31
32
33
34
35
# File 'lib/rig/account.rb', line 29

def get
  return ENV['RIG_ACCOUNT'] if ENV['RIG_ACCOUNT']
  return Rig.config[:account] if Rig.config[:account]
  return Rig.config[:default_account] if Rig.config[:default_account]
  return Rig.config[:accounts].first if Rig.config[:accounts] && Rig.config[:accounts].count > 0
  "default"
end

.saveObject



37
38
39
40
# File 'lib/rig/account.rb', line 37

def save
  name = Rig.[:name]
  Rig::Model::Account.save(name, Rig.)
end