Sha256: ad785bb5bbbe1aab2b6f90e863173cd7a5b689598906a8065de2d783719fdf94

Contents?: true

Size: 1.62 KB

Versions: 38

Compression:

Stored size: 1.62 KB

Contents

module Vedeu

  # Provides a mechanism to help configure and use Vedeu.
  #
  module DSL

    # Returns an instance of the DSL class including {Vedeu::DSL}.
    #
    # @param model [void] The model class which the DSL class is
    #   wrapping.
    # @param client [void] The class where the DSL methods are being
    #   used.
    # @return [void] An instance of the DSL class.
    def initialize(model, client = nil)
      @model  = model
      @client = client
    end

    protected

    # @!attribute [r] client
    # @return [Object] The object instance where the DSL is being
    #   used.
    attr_reader :client

    # @!attribute [r] model
    # @return [void] The new model object which the DSL is
    #   constructing.
    attr_reader :model

    private

    # Returns the default attributes for the new model.
    #
    # @note
    #   Specific DSL classes may be overriding this method.
    #
    # @return [Hash<Symbol => void>]
    def attributes
      {
        client: client,
        parent: model,
      }
    end

    # :nocov:

    # Attempts to find the missing method on the client object.
    #
    # @param method [Symbol] The name of the method sought.
    # @param args [Array] The arguments which the method was to be
    #   invoked with.
    # @param block [Proc] The optional block provided to the method.
    # @return [void]
    def method_missing(method, *args, &block)
      Vedeu.log(type:    :debug,
                message: "!!!method_missing '#{method}' " \
                         "(#{client.inspect})".freeze)

      client.send(method, *args, &block) if client
    end

    # :nocov:

  end # DSL

end # Vedeu

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
vedeu-0.6.64 lib/vedeu/dsl/dsl.rb
vedeu-0.6.63 lib/vedeu/dsl/dsl.rb
vedeu-0.6.62 lib/vedeu/dsl/dsl.rb
vedeu-0.6.61 lib/vedeu/dsl/dsl.rb
vedeu-0.6.60 lib/vedeu/dsl/dsl.rb
vedeu-0.6.59 lib/vedeu/dsl/dsl.rb
vedeu-0.6.58 lib/vedeu/dsl/dsl.rb
vedeu-0.6.57 lib/vedeu/dsl/dsl.rb
vedeu-0.6.56 lib/vedeu/dsl/dsl.rb
vedeu-0.6.54 lib/vedeu/dsl/dsl.rb
vedeu-0.6.53 lib/vedeu/dsl/dsl.rb
vedeu-0.6.52 lib/vedeu/dsl/dsl.rb
vedeu-0.6.51 lib/vedeu/dsl/dsl.rb
vedeu-0.6.50 lib/vedeu/dsl/dsl.rb
vedeu-0.6.49 lib/vedeu/dsl/dsl.rb
vedeu-0.6.48 lib/vedeu/dsl/dsl.rb
vedeu-0.6.47 lib/vedeu/dsl/dsl.rb
vedeu-0.6.46 lib/vedeu/dsl/dsl.rb
vedeu-0.6.45 lib/vedeu/dsl/dsl.rb
vedeu-0.6.44 lib/vedeu/dsl/dsl.rb