class Sequoia::Entity

Class: Resulting storage of configuration data

Once it initialized - it can’t be modified

Public Class Methods

create(store=Store.new) click to toggle source

Factory: Create new instance of entity

Returns: {Sequoia::Entity}

# File lib/sequoia/entity.rb, line 16
def self.create(store=Store.new)
  keys = store.keys

  values = store.values.map do |value|
    value.class == Store ? create(value) : value
  end

  if keys.any?
    new(*keys).new(*values).freeze
  else
    Object.new.freeze
  end
end

Public Instance Methods

inspect()
Alias for: to_s
method_missing(*) click to toggle source

Do not raise exceptions when key not found

# File lib/sequoia/entity.rb, line 60
def method_missing(*)
  return nil
end
pretty_inspect() click to toggle source

Returns: {String} a pretty printed object

# File lib/sequoia/entity.rb, line 54
def pretty_inspect
  PP.pp(to_hash, '')
end
to_hash() click to toggle source

Convert content of entity to hash

TODO: Deep to_hash

Returns: {Hash} Hash of all keys and values

# File lib/sequoia/entity.rb, line 37
def to_hash
  members.each_with_object({}) { |key, obj| obj[key] = self[key] }
end
to_s() click to toggle source

Represent content of entity as hash string

Returns: {String} String with keys and values in hash format

# File lib/sequoia/entity.rb, line 46
def to_s
  to_hash.to_s
end
Also aliased as: inspect