Class: Rack::Mount::Analysis::Splitting::Key

Inherits:
Struct
  • Object
show all
Defined in:
lib/rack/mount/analysis/splitting.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#indexObject

Returns the value of attribute index

Returns:

  • (Object)

    the current value of index



8
9
10
# File 'lib/rack/mount/analysis/splitting.rb', line 8

def index
  @index
end

#methodObject

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



8
9
10
# File 'lib/rack/mount/analysis/splitting.rb', line 8

def method
  @method
end

#separatorsObject

Returns the value of attribute separators

Returns:

  • (Object)

    the current value of separators



8
9
10
# File 'lib/rack/mount/analysis/splitting.rb', line 8

def separators
  @separators
end

Class Method Details

.split(value, separator_pattern) ⇒ Object



9
10
11
12
13
14
# File 'lib/rack/mount/analysis/splitting.rb', line 9

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



16
17
18
# File 'lib/rack/mount/analysis/splitting.rb', line 16

def call(cache, obj)
  (cache[method] ||= self.class.split(obj.send(method), separators))[index]
end

#call_source(cache, obj) ⇒ Object



20
21
22
# File 'lib/rack/mount/analysis/splitting.rb', line 20

def call_source(cache, obj)
  "(#{cache}[:#{method}] ||= Analysis::Splitting::Key.split(#{obj}.#{method}, #{separators.inspect}))[#{index}]"
end

#inspectObject



24
25
26
# File 'lib/rack/mount/analysis/splitting.rb', line 24

def inspect
  "#{method}[#{index}].split(#{separators.inspect})"
end