module Remap::Extensions::Object

Public Instance Methods

_(&block) click to toggle source

Fallback validation method

@yield if block is provided

@raise unless block is provided

# File lib/remap/extensions/object.rb, line 17
def _(&block)
  unless block
    return _ { raise _1 }
  end

  block["Expected a state, got [#{self}] (#{self.class})"]
end
formatted() click to toggle source

return [Any]

# File lib/remap/extensions/object.rb, line 52
def formatted
  self
end
get(*path, trace: []) { || ... } click to toggle source

Fallback method used when get is called on an object that does not respond to get

Block is invoked, if provided Otherwise a symbol is thrown

@param path [Array<Key>]

# File lib/remap/extensions/object.rb, line 38
def get(*path, trace: [], &fallback)
  return self if path.empty?

  unless fallback
    return get(*path, trace: trace) do
      throw :ignore, trace + path
    end
  end

  yield
end
paths() click to toggle source

@return [Array]

@see Extension::Paths::Hash

# File lib/remap/extensions/object.rb, line 28
def paths
  []
end
to_hash() click to toggle source

@return [Any]

# File lib/remap/extensions/object.rb, line 8
def to_hash
  self
end