Module: Rfm::Factory

Extended by:
Config
Defined in:
lib/rfm/base.rb,
lib/rfm/utilities/factory.rb

Defined Under Namespace

Classes: DbFactory, LayoutFactory, ScriptFactory, ServerFactory

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Config

config, config_clear, get_config, sanitize_config

Class Attribute Details

.modelsObject

Returns the value of attribute models.



132
133
134
# File 'lib/rfm/base.rb', line 132

def models
  @models
end

Class Method Details

.db(*conf) ⇒ Object Also known as: database

Returns Rfm::Db instance, given config hash or array



176
177
178
179
180
181
182
183
# File 'lib/rfm/utilities/factory.rb', line 176

def db(*conf)
	options = get_config(*conf)
	name = options[:strings].delete_at(0) || options[:database]
	 = options[:strings].delete_at(0) || options[:account_name]
	password = options[:strings].delete_at(0) || options[:password]
s = server(options)
s[name, , password, options]
end

.layout(*conf) ⇒ Object

Returns Rfm::Layout instance, given config hash or array



188
189
190
191
192
193
# File 'lib/rfm/utilities/factory.rb', line 188

def layout(*conf)
	options = get_config(*conf)
	name = options[:strings].delete_at(0) || options[:layout]
d = db(options)
d[name, options]
end

.modelize(*args) ⇒ Object

Shortcut to Factory.db().layouts.modelize() If first parameter is regex, it is used for modelize filter. Otherwise, parameters are passed to Factory.database



137
138
139
140
# File 'lib/rfm/base.rb', line 137

def modelize(*args)
	regx = args[0].is_a?(Regexp) ? args.shift : /.*/
	db(*args).layouts.modelize(regx)
end

.server(*conf) ⇒ Object

Returns Rfm::Server instance, given config hash or array



165
166
167
168
169
170
171
# File 'lib/rfm/utilities/factory.rb', line 165

def server(*conf)
	options = get_config(*conf)
#server = servers[server_name, options]
# These disconnect servers from the ServerFactory hash, but it breaks the ActiveModel spec suite.
#Rfm::Server.new(server_name, options.rfm_filter(:account_name, :password, :delete=>true))
Rfm::Server.new(options)
end

.serversObject



160
161
162
# File 'lib/rfm/utilities/factory.rb', line 160

def servers
	@servers ||= ServerFactory.new
end