class Mongoid::PathExtension
Constants
- VERSION
Public Class Methods
demongoize(value)
click to toggle source
# File lib/mongoid/path_extension.rb, line 51 def demongoize(value) PathExtension.new(value) end
evolve(value)
click to toggle source
# File lib/mongoid/path_extension.rb, line 62 def evolve(value) case value when PathExtension then value.mongoize else value end end
mongoize(value)
click to toggle source
# File lib/mongoid/path_extension.rb, line 55 def mongoize(value) case value when PathExtension then value.mongoize else value end end
new(str)
click to toggle source
Calls superclass method
# File lib/mongoid/path_extension.rb, line 5 def initialize(str) super str.to_s @str = str.to_s end
Public Instance Methods
absolute()
click to toggle source
# File lib/mongoid/path_extension.rb, line 23 def absolute ['/', @str].join end
ancestor_paths()
click to toggle source
# File lib/mongoid/path_extension.rb, line 31 def ancestor_paths return unless has_parent? res = [] components[0..-2].each_with_index do |component, index| res << components[0..index].join('/') end res end
components()
click to toggle source
# File lib/mongoid/path_extension.rb, line 10 def components return [] unless @str.present? @str.split('/') end
has_parent?()
click to toggle source
# File lib/mongoid/path_extension.rb, line 27 def has_parent? components.length > 1 end
parent_path()
click to toggle source
# File lib/mongoid/path_extension.rb, line 40 def parent_path return unless has_parent? components[0..-2].join('/') end
parent_permalink()
click to toggle source
# File lib/mongoid/path_extension.rb, line 45 def parent_permalink return unless has_parent? components[-2] end
permalink()
click to toggle source
# File lib/mongoid/path_extension.rb, line 19 def permalink components.last end
root()
click to toggle source
# File lib/mongoid/path_extension.rb, line 15 def root components.first end