Class: Rack::Mount::Analysis::Splitting::Key
- Inherits:
-
Array
- Object
- Array
- Rack::Mount::Analysis::Splitting::Key
- Defined in:
- lib/rack/mount/analysis/splitting.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(cache, obj) ⇒ Object
- #call_source(cache, obj) ⇒ Object
-
#initialize(method, index, separators) ⇒ Key
constructor
A new instance of Key.
Constructor Details
#initialize(method, index, separators) ⇒ Key
Returns a new instance of Key.
9 10 11 |
# File 'lib/rack/mount/analysis/splitting.rb', line 9 def initialize(method, index, separators) replace([method, index, separators]) end |
Class Method Details
.split(value, separator_pattern) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rack/mount/analysis/splitting.rb', line 13 def self.split(value, separator_pattern) keys = value.split(separator_pattern) keys.shift if keys[0] == '' keys << NULL keys end |
Instance Method Details
#call(cache, obj) ⇒ Object
20 21 22 |
# File 'lib/rack/mount/analysis/splitting.rb', line 20 def call(cache, obj) (cache[self[0]] ||= self.class.split(obj.send(self[0]), self[2]))[self[1]] end |
#call_source(cache, obj) ⇒ Object
24 25 26 |
# File 'lib/rack/mount/analysis/splitting.rb', line 24 def call_source(cache, obj) "(#{cache}[:#{self[0]}] ||= Analysis::Splitting::Key.split(#{obj}.#{self[0]}, #{self[2].inspect}))[#{self[1]}]" end |