Class: Adminix::Entities::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/adminix/entities/variable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Variable

Returns a new instance of Variable.



22
23
24
25
# File 'lib/adminix/entities/variable.rb', line 22

def initialize(opts = {})
  @key = opts[:key]
  @value = opts[:value]
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



4
5
6
# File 'lib/adminix/entities/variable.rb', line 4

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/adminix/entities/variable.rb', line 4

def value
  @value
end

Class Method Details

.all(service) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/adminix/entities/variable.rb', line 6

def self.all(service)
  return [] unless Adminix.config.credentials_defined?

  success, result = Helpers::NetHTTP.get("services/#{service.id}/options")
  return [] unless success

  variables = result.map do |o|
    Variable.new(
      key: o['key'],
      value: o['value']
    )
  end

  variables
end

Instance Method Details

#to_bash_exportObject



27
28
29
# File 'lib/adminix/entities/variable.rb', line 27

def to_bash_export
  "export #{key}=\"#{value}\""
end