Module: Flatten
- Extended by:
- GuardMethods, UtilityMethods
- Defined in:
- lib/flatten.rb,
lib/flatten/version.rb,
lib/flatten/separator.rb,
lib/flatten/deprecations.rb,
lib/flatten/guard_methods.rb,
lib/flatten/utility_methods.rb
Overview
Provides smash-key access to a Hash.
‘foo’=>{‘bar’=>‘bingo’}.smash #=> ‘foo‘foo.bar’=>‘bingo’ ‘foo‘foo.bar’=>‘bingo’.unsmash => ‘foo’=>{‘bar’=>‘bingo’}
Defined Under Namespace
Modules: Deprecations, GuardMethods, UtilityMethods Classes: Separator
Constant Summary collapse
- DEFAULT_SEPARATOR =
The default separator, used if not specified in command’s options hash.
'.'.freeze
- VERSION =
"0.1.1"
Instance Method Summary collapse
-
#smash(options = {}) ⇒ Hash<String,Object>
Returns a smash version of self using the options provided.
-
#smash!(options = {}) ⇒ Hash<String,Object>
Replaces self with smash version of itself.
-
#smash_each(options = {}, &block) ⇒ Object
Used internally by both Flatten::Utility#smash and Flatten::Utility#unsmash.
-
#smash_fetch(*args, &block) ⇒ Object
Follows semantics of Hash#fetch.
-
#smash_get(smash_key, options = {}) ⇒ Object
Follows semantics of Hash#[] without support for Hash#default_proc.
-
#unsmash(options = {}) ⇒ Hash<String,Object>
Returns a deeply-nested hash version of self.
-
#unsmash!(options = {}) ⇒ Hash<String,Object>
Replaces self with deeply-nested version of self.
Methods included from GuardMethods
Methods included from UtilityMethods
Instance Method Details
#smash(options = {}) ⇒ Hash<String,Object>
Returns a smash version of self using the options provided.
28 29 30 |
# File 'lib/flatten.rb', line 28 def smash( = {}) Flatten.smash(self, ) end |
#smash!(options = {}) ⇒ Hash<String,Object>
Replaces self with smash version of itself.
36 37 38 |
# File 'lib/flatten.rb', line 36 def smash!( = {}) self.replace(smash, ) end |
#smash_each(options = {}) {|| ... } ⇒ void #smash_each(options = {}) ⇒ Enumerator<(smash_key,value)>
Used internally by both Flatten::Utility#smash and Flatten::Utility#unsmash
51 52 53 |
# File 'lib/flatten.rb', line 51 def smash_each( = {}, &block) Flatten.smash_each(self, , &block) end |
#smash_fetch(smash_key, options = {}) ⇒ Object #smash_fetch(smash_key, default, options = {}) ⇒ default #smash_fetch(smash_key, options = {}) { ... } ⇒ Object
Follows semantics of Hash#fetch
69 70 71 |
# File 'lib/flatten.rb', line 69 def smash_fetch(*args, &block) Flatten.smash_fetch(self, *args, &block) end |
#smash_get(smash_key, options = {}) ⇒ Object
Follows semantics of Hash#[] without support for Hash#default_proc
78 79 80 |
# File 'lib/flatten.rb', line 78 def smash_get(*args) Flatten.smash_get(self, *args) end |
#unsmash(options = {}) ⇒ Hash<String,Object>
Returns a deeply-nested hash version of self.
86 87 88 |
# File 'lib/flatten.rb', line 86 def unsmash( = {}) Flatten.unsmash(self, ) end |
#unsmash!(options = {}) ⇒ Hash<String,Object>
Replaces self with deeply-nested version of self.
94 95 96 |
# File 'lib/flatten.rb', line 94 def unsmash!( = {}) self.replace(unsmash, ) end |