Class: Hash
- Includes:
- Compact, Cross, EnsureKeys, Extract, Extras
- Defined in:
- lib/vex/base/hash/easy_access.rb,
lib/vex/base/hash/inspect.rb,
lib/vex/base/hash/ensure_keys.rb,
lib/vex/base/hash/simple_access_methods.rb,
lib/vex/base/hash/extract.rb,
lib/vex/base/hash/compact.rb,
lib/vex/base/object/insp.rb,
lib/vex/base/hash/extras.rb,
lib/vex/base/hash/cross.rb
Overview
-
allows to use hash.xx.yy where you would have to use
hash[:yy] etc.
-
supports
hash.xx?
as a shortcut for hash.key?(:xx) || hash.key?(“xx”)
-
does not support assignment, though; i.e.
hash.yy = zz
will raise a NoMethodError.
Direct Known Subclasses
Defined Under Namespace
Modules: Compact, Cross, EasyAccess, EnsureKeys, Etest, Extract, Extras, SimpleAccessMethods
Instance Method Summary collapse
- #easy_access ⇒ Object
- #easy_access! ⇒ Object
- #easy_accessible? ⇒ Boolean
- #insp ⇒ Object
- #inspect ⇒ Object
- #with_simple_access ⇒ Object
Methods included from Cross
Methods included from Extras
#delete_all, #hmap, included, #select_entries
Methods included from Compact
Methods included from Extract
Methods included from EnsureKeys
Instance Method Details
#easy_access ⇒ Object
77 78 79 |
# File 'lib/vex/base/hash/easy_access.rb', line 77 def easy_access dup.easy_access! end |
#easy_access! ⇒ Object
81 82 83 84 |
# File 'lib/vex/base/hash/easy_access.rb', line 81 def easy_access! # extend always returns self extend(EasyAccess) end |
#easy_accessible? ⇒ Boolean
86 87 88 |
# File 'lib/vex/base/hash/easy_access.rb', line 86 def easy_accessible? @easy_accessible end |
#insp ⇒ Object
47 48 49 |
# File 'lib/vex/base/object/insp.rb', line 47 def insp self.class == Hash && instance_variables.empty? ? insp_body : super end |
#inspect ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/vex/base/hash/inspect.rb', line 3 def inspect "{" + to_a.sort_by do |k, v| k.to_s end.map do |k,v| "#{k.inspect} => #{v.inspect}" end.join(", ") + "}" end |
#with_simple_access ⇒ Object
2 3 4 5 |
# File 'lib/vex/base/hash/simple_access_methods.rb', line 2 def with_simple_access Deprecation.report "Hash#with_simple_access", "Hash#easy_access" easy_access! end |