Class: Rfm::Factory::ScriptFactory

Inherits:
Util::CaseInsensitiveHash
  • Object
show all
Defined in:
lib/rfm_factory.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, database) ⇒ ScriptFactory

Returns a new instance of ScriptFactory.



60
61
62
63
64
# File 'lib/rfm_factory.rb', line 60

def initialize(server, database)
  @server = server
  @database = database
  @loaded = false
end

Instance Method Details

#[](script_name) ⇒ Object



66
67
68
# File 'lib/rfm_factory.rb', line 66

def [](script_name)
  super or (self[script_name] = Rfm::Script.new(script_name, @database))
end

#allObject



70
71
72
73
74
75
76
77
78
79
# File 'lib/rfm_factory.rb', line 70

def all
  if !@loaded
    Rfm::Result::ResultSet.new(@server, @server.do_action(@server.state[:account_name], @server.state[:password], '-scriptnames', {"-db" => @database.name}).body).each {|record|
      name = record['SCRIPT_NAME']
      self[name] = Rfm::Script.new(name, @database) if self[name] == nil
    }
    @loaded = true
  end
  self.values
end