Sha256: fb41459942b2e8e261c63520dbebadb666f214a2444fe797e1b5ce69a0a4fd2d

Contents?: true

Size: 1.99 KB

Versions: 12

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true

module Vedeu

  module DSL

    # Provides DSL methods for Vedeu::Geometries::Geometry objects.
    #
    # @api public
    #
    module Geometry

      # @macro module_singleton_methods
      module SingletonMethods

        # {include:file:docs/dsl/by_method/geometry.md}
        # @macro param_name
        # @macro param_block
        # @macro raise_requires_block
        # @macro raise_missing_required
        # @return [Vedeu::Geometries::Geometry]
        # @see Vedeu::Geometries::DSL
        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

      end # SingletonMethods

      # Provide additional behaviour as instance methods.
      #
      module InstanceMethods

        # {include:file:docs/dsl/by_method/geometry.md}
        # @macro param_name
        # @macro param_block
        # @macro raise_requires_block
        # @macro raise_missing_required
        # @return [Vedeu::Geometries::Geometry]
        # @see Vedeu::Geometries::DSL
        def geometry(name = nil, &block)
          raise Vedeu::Error::RequiresBlock unless block_given?

          model_name = name ? name : model.name

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

      end # InstanceMethods

      # @macro module_included
      def self.included(klass)
        klass.extend(Vedeu::DSL::Geometry::SingletonMethods)
        klass.include(Vedeu::DSL::Geometry::InstanceMethods)
      end

    end # Geometry

  end # DSL

end # Vedeu

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
vedeu-0.8.32 lib/vedeu/dsl/geometry.rb
vedeu-0.8.31 lib/vedeu/dsl/geometry.rb
vedeu-0.8.30 lib/vedeu/dsl/geometry.rb
vedeu-0.8.29 lib/vedeu/dsl/geometry.rb
vedeu-0.8.28 lib/vedeu/dsl/geometry.rb
vedeu-0.8.27 lib/vedeu/dsl/geometry.rb
vedeu-0.8.26 lib/vedeu/dsl/geometry.rb
vedeu-0.8.25 lib/vedeu/dsl/geometry.rb
vedeu-0.8.24 lib/vedeu/dsl/geometry.rb
vedeu-0.8.23 lib/vedeu/dsl/geometry.rb
vedeu-0.8.22 lib/vedeu/dsl/geometry.rb
vedeu-0.8.21 lib/vedeu/dsl/geometry.rb