Class: Udongo::ObjectPath

Inherits:
Object
  • Object
show all
Defined in:
lib/udongo/object_path.rb

Class Method Summary collapse

Class Method Details

.cleanup(value) ⇒ Object



17
18
19
# File 'lib/udongo/object_path.rb', line 17

def self.cleanup(value)
  value.to_s.gsub('_decorator', '')
end

.find(object) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/udongo/object_path.rb', line 2

def self.find(object)
  unless object.is_a?(Array)
    return cleanup("#{object.class.name.underscore}_path")
  end

  object.map do |item|
    item.is_a?(Symbol) ? "#{item}" : cleanup(item.class.name.underscore)
  end.join('_') << '_path'
end

.remove_symbols(object) ⇒ Object



12
13
14
15
# File 'lib/udongo/object_path.rb', line 12

def self.remove_symbols(object)
  return object unless object.is_a?(Array)
  object.select { |o| !o.is_a?(Symbol) }
end