Class: Facter::Util::Aix::ODMQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/util/aix/odm_query.rb

Constant Summary collapse

REPOS =
%w[CuAt CuDv PdAt PdDv].freeze

Instance Method Summary collapse

Constructor Details

#initializeODMQuery

Returns a new instance of ODMQuery.



14
15
16
17
18
# File 'lib/facter/util/aix/odm_query.rb', line 14

def initialize
  @query = ''
  @conditions = []
  @log = Facter::Log.new(self)
end

Instance Method Details

#equals(field, value) ⇒ Object



20
21
22
23
# File 'lib/facter/util/aix/odm_query.rb', line 20

def equals(field, value)
  @conditions << "#{field}='#{value}'"
  self
end

#executeObject



30
31
32
33
34
35
36
37
38
# File 'lib/facter/util/aix/odm_query.rb', line 30

def execute
  result = nil
  REPOS.each do |repo|
    break if result && !result.empty?

    result = Facter::Core::Execution.execute("#{query} #{repo}", logger: @log)
  end
  result
end

#like(field, value) ⇒ Object



25
26
27
28
# File 'lib/facter/util/aix/odm_query.rb', line 25

def like(field, value)
  @conditions << "#{field} like '#{value}'"
  self
end

#queryObject



40
41
42
# File 'lib/facter/util/aix/odm_query.rb', line 40

def query
  "odmget -q \"#{@conditions.join(' AND ')}\""
end