Module: Cobbler::Common::Finders::ClassMethods

Defined in:
lib/cobbler/common/finders.rb

Instance Method Summary collapse

Instance Method Details

#find(&block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/cobbler/common/finders.rb', line 36

def find(&block)
    raise "No idea how to fetch a list of myself, as no find_all method is defined" unless api_methods[:find_all]
    result = []
    in_transaction { make_call(api_methods[:find_all]) }.to_a.each do |record|
        c_record = new(record,false)
        result << c_record
        yield(c_record) if block_given?
    end
    return result
end

#find_one(name) ⇒ Object



47
48
49
50
51
# File 'lib/cobbler/common/finders.rb', line 47

def find_one(name)
    raise "No idea how to fetch myself, as no find_one method is defined" unless api_methods[:find_one]
    properties = in_transaction { make_call(api_methods[:find_one],name) }
    valid_properties?(properties) ? new(properties,false) : nil
end