Class: Configliere::Param
- Inherits:
-
ParamParent
- Object
- Hash
- ParamParent
- Configliere::Param
- Includes:
- EncryptedParam
- Defined in:
- lib/configliere/param.rb,
lib/configliere/encrypted.rb
Overview
Hash of fields to store.
Any field name beginning with ‘decrypted_’ automatically creates a counterpart ‘encrypted_’ field using the encrypt_pass.
Constant Summary
Constants inherited from Hash
Instance Attribute Summary
Attributes included from EncryptedParam
Instance Method Summary collapse
- #[](param) ⇒ Object
- #[]=(param, val) ⇒ Object
-
#defaults(hsh) ⇒ Object
Incorporates the given settings.
- #delete(param) ⇒ Object
-
#initialize(constructor = {}) ⇒ Param
constructor
A new instance of Param.
-
#resolve! ⇒ Object
Finalize and validate params.
-
#to_hash ⇒ Hash
The mash as a Hash with string keys.
- #use(*args) ⇒ Object
-
#validate! ⇒ Object
Check that all defined params are valid.
Methods included from EncryptedParam
Methods inherited from ParamParent
Methods inherited from Hash
#compact, #compact!, #deep_delete, #deep_get, #deep_merge, #deep_merge!, #deep_set, #to_sash
Constructor Details
Instance Method Details
#[](param) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/configliere/param.rb', line 78 def [] param if param =~ /\./ return deep_get( *convert_key(param) ) else super param end end |
#[]=(param, val) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/configliere/param.rb', line 70 def []= param, val if param =~ /\./ return deep_set( *(convert_key(param) | [val]) ) else super param, val end end |
#defaults(hsh) ⇒ Object
Incorporates the given settings. alias for deep_merge! Existing values not given in the hash
56 57 58 |
# File 'lib/configliere/param.rb', line 56 def defaults hsh deep_merge! hsh end |
#delete(param) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/configliere/param.rb', line 86 def delete param if param =~ /\./ return deep_delete( *convert_key(param) ) else super param end end |
#resolve! ⇒ Object
Finalize and validate params
61 62 63 64 |
# File 'lib/configliere/param.rb', line 61 def resolve! super() validate! end |
#to_hash ⇒ Hash
Returns The mash as a Hash with string keys.
40 41 42 |
# File 'lib/configliere/param.rb', line 40 def to_hash Hash.new(default).merge(self) end |
#use(*args) ⇒ Object
94 95 96 97 98 |
# File 'lib/configliere/param.rb', line 94 def use *args hsh = args.pop if args.last.is_a?(Hash) Configliere.use(*args) self.deep_merge!(hsh) unless hsh.nil? end |
#validate! ⇒ Object
Check that all defined params are valid
66 67 68 |
# File 'lib/configliere/param.rb', line 66 def validate! super() end |