Module: Rfm::Config
- Extended by:
- Config
- Defined in:
- lib/rfm/utilities/config.rb
Overview
Top level config hash accepts any defined config parameters, or group-name keys pointing to config subsets. The subsets can be any grouping of defined config parameters, as a hash. See CONFIG_KEYS for defined config parameters.
Constant Summary collapse
- CONFIG_KEYS =
%w( file_name file_path parser host port account_name password database layout ignore_bad_data ssl root_cert root_cert_name root_cert_path warn_on_redirect raise_on_401 timeout log_actions log_responses log_parser use parent grammar field_mapping capture_strings_with logger )
- CONFIG_DONT_STORE =
capture_strings_with)
%w(strings using parents symbols objects)
Instance Method Summary collapse
-
#config(*args, &block) ⇒ Object
Set @config with args & options hash.
-
#config_clear(*args) ⇒ Object
Sets @config just as above config method, but clears @config first.
-
#get_config(*arguments) ⇒ Object
Gets top level settings, merged with local and ad-hoc settings.
- #log ⇒ Object
- #state(*args) ⇒ Object
Instance Method Details
#config(*args, &block) ⇒ Object
Set @config with args & options hash. Args should be symbols representing configuration groups, with optional config hash as last arg, to be merged on top. Returns @config.
Sets @config with :use => :group1, :layout => ‘my_layout’
config :group1, :layout => 'my_layout
Factory.server, Factory.database, Factory.layout, and Base.config can take a string as the first argument, refering to the relevent server/database/layout name.
Pass a string as the first argument, to be used in the immediate context
config 'my_layout' # in the model, to set model configuration
Factory.layout 'my_layout', :my_group # to get a layout from settings in :my_group
60 61 62 63 64 65 |
# File 'lib/rfm/utilities/config.rb', line 60 def config(*args, &block) @config ||= {} return @config if args.empty? config_write(*args, &block) @config end |
#config_clear(*args) ⇒ Object
Sets @config just as above config method, but clears @config first.
68 69 70 71 72 73 |
# File 'lib/rfm/utilities/config.rb', line 68 def config_clear(*args) @config = {} return @config if args.empty? config_write(*args) @config end |
#get_config(*arguments) ⇒ Object
Gets top level settings, merged with local and ad-hoc settings.
get_config :layout => 'my_layout
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/rfm/utilities/config.rb', line 87 def get_config(*arguments) #puts caller_locations(1,1)[0] args = arguments.clone @config ||= {} = (*args) strings = [:strings].rfm_force_array || [] symbols = [:symbols].rfm_force_array.concat([:hash][:use].rfm_force_array) || [] objects = [:objects].rfm_force_array || [] rslt = config_merge_with_parent(symbols).merge([:hash]) #using = rslt[:using].rfm_force_array sanitize_config(rslt, CONFIG_DONT_STORE, false) rslt[:using].delete "" rslt[:parents].delete "" rslt.merge(:strings=>strings, :objects=>objects) end |
#state(*args) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/rfm/utilities/config.rb', line 104 def state(*args) return @_state if args.empty? && !@state.nil? && (RUBY_VERSION[0,1].to_i > 1 ? (caller_locations(1,1) == @_last_state_caller) : false) @_state = get_config(*args) (@_last_state_caller = caller_locations(1,1)) if RUBY_VERSION[0,1].to_i > 1 @_state end |