Module: Vedeu::DSL::Geometry::SingletonMethods

Defined in:
lib/vedeu/dsl/geometry.rb

Overview

Provide additional behaviour as singleton methods to the including class or module.

Instance Method Summary collapse

Instance Method Details

#geometry(name = nil, &block) ⇒ Vedeu::Geometries::Geometry

Parameters:

  • name (NilClass|Symbol|String) (defaults to: nil)

    The name of the model or target model to act upon. May default to ‘Vedeu.focus`.

  • block (Proc)

Returns:

Raises:

See Also:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vedeu/dsl/geometry.rb', line 23

def geometry(name = nil, &block)
  # Alternative implementation which treats `Vedeu.geometry`
  # as `Vedeu.geometries` if no name or block is given.
  #
  # if name && block_given?
  #   Vedeu::Geometries::Geometry.build(name: name, &block).store
  #
  # else
  #   Vedeu.geometries
  #
  # end

  raise Vedeu::Error::MissingRequired unless name
  raise Vedeu::Error::RequiresBlock unless block_given?

  Vedeu::Geometries::Geometry.build(name: name, &block).store
end