Module: Vedeu::Repositories::Defaults Private

Included in:
Buffers::Empty, Buffers::View, Editor::Document, Geometry::Move, Models::Cell
Defined in:
lib/vedeu/repositories/defaults.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Some classes expect a certain set of attributes when initialized, this module uses the #defaults method of the class to provide missing attribute keys (and values).

Instance Method Summary collapse

Instance Method Details

#initialize(attributes = {}) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

If a particular key is missing from the attributes parameter, then it is added with the respective value from #defaults.

Returns a new instance of the class including this module.

Parameters:

  • attributes (Hash) (defaults to: {})


23
24
25
26
27
# File 'lib/vedeu/repositories/defaults.rb', line 23

def initialize(attributes = {})
  defaults.merge!(attributes).each do |key, value|
    instance_variable_set("@#{key}", value || defaults.fetch(key))
  end
end