Sha256: 8745dde6384d949c0db8cc8e45573b949f4bd5cb210ce8539fd6b008e3e58230

Contents?: true

Size: 500 Bytes

Versions: 4

Compression:

Stored size: 500 Bytes

Contents

class Udongo::ObjectPath
  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

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

  private

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
udongo-1.0.3 lib/udongo/object_path.rb
udongo-1.0.2 lib/udongo/object_path.rb
udongo-1.0.1 lib/udongo/object_path.rb
udongo-1.0.0 lib/udongo/object_path.rb