class Rosetta::Element

Attributes

object[R]

Public Class Methods

new(object) click to toggle source
# File lib/rosetta/element.rb, line 5
def initialize(object)
  @object = object
end

Public Instance Methods

[](key) click to toggle source
# File lib/rosetta/element.rb, line 13
def [](key)
  object.dig(*key.split("."))
end
properties() click to toggle source
# File lib/rosetta/element.rb, line 9
def properties
  properties_of(object)
end

Private Instance Methods

properties_of(obj) click to toggle source
# File lib/rosetta/element.rb, line 19
def properties_of(obj)
  obj.flat_map do |key, val|
    case val
    when Hash
      properties_of(val).map{ |header| [key, header].join('.') }
    else
      key
    end
  end
end