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
-
.models ⇒ Object
Returns the value of attribute models.
Class Method Summary collapse
-
.db(*conf) ⇒ Object
(also: database)
Returns Rfm::Db instance, given config hash or array.
-
.layout(*conf) ⇒ Object
Returns Rfm::Layout instance, given config hash or array.
-
.modelize(*args) ⇒ Object
Shortcut to Factory.db().layouts.modelize() If first parameter is regex, it is used for modelize filter.
-
.server(*conf) ⇒ Object
Returns Rfm::Server instance, given config hash or array.
- .servers ⇒ Object
Methods included from Config
config, config_clear, get_config, sanitize_config
Class Attribute Details
.models ⇒ Object
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) = get_config(*conf) name = [:strings].delete_at(0) || [:database] account_name = [:strings].delete_at(0) || [:account_name] password = [:strings].delete_at(0) || [:password] s = server() s[name, account_name, password, ] 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) = get_config(*conf) name = [:strings].delete_at(0) || [:layout] d = db() d[name, ] 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) = 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() end |
.servers ⇒ Object
160 161 162 |
# File 'lib/rfm/utilities/factory.rb', line 160 def servers @servers ||= ServerFactory.new end |