Class: Unobtainium::PathedHash
- Inherits:
-
Object
- Object
- Unobtainium::PathedHash
- Defined in:
- lib/unobtainium/pathed_hash.rb
Overview
Direct Known Subclasses
Constant Summary collapse
- READ_METHODS =
[ :[], :default, :delete, :fetch, :has_key?, :include?, :key?, :member?, ].freeze
- WRITE_METHODS =
[ :[]=, :store, ].freeze
Instance Attribute Summary collapse
-
#separator ⇒ Object
The separator is the character or pattern splitting paths.
Instance Method Summary collapse
-
#initialize(init = {}) ⇒ PathedHash
constructor
Initializer.
- #method_missing(meth, *args, &block) ⇒ Object
-
#respond_to?(meth) ⇒ Boolean
Map any missing method to the driver implementation.
-
#split_pattern ⇒ Object
Returns the pattern to split paths at.
- #to_s ⇒ Object
Constructor Details
#initialize(init = {}) ⇒ PathedHash
Initializer
19 20 21 22 |
# File 'lib/unobtainium/pathed_hash.rb', line 19 def initialize(init = {}) @data = init @separator = '.' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/unobtainium/pathed_hash.rb', line 88 def method_missing(meth, *args, &block) if not @data.nil? and @data.respond_to?(meth) return @data.send(meth.to_s, *args, &block) end return super end |
Instance Attribute Details
#separator ⇒ Object
The separator is the character or pattern splitting paths
25 26 27 |
# File 'lib/unobtainium/pathed_hash.rb', line 25 def separator @separator end |
Instance Method Details
#respond_to?(meth) ⇒ Boolean
Map any missing method to the driver implementation
81 82 83 84 85 86 |
# File 'lib/unobtainium/pathed_hash.rb', line 81 def respond_to?(meth) if not @data.nil? and @data.respond_to?(meth) return true end return super end |
#split_pattern ⇒ Object
Returns the pattern to split paths at
36 37 38 |
# File 'lib/unobtainium/pathed_hash.rb', line 36 def split_pattern /(?<!\\)#{Regexp.escape(@separator)}/ end |
#to_s ⇒ Object
75 76 77 |
# File 'lib/unobtainium/pathed_hash.rb', line 75 def to_s @data.to_s end |