Sha256: 33cfa5b9d83c4fd4cd383432b480e8f5f7654f4ec3dc1552f0bbfbfaf8bf7cf4

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

module Vedeu

  module DSL

    # Provides helper methods for building views.
    #
    module Use

      extend self

      # Use the specified interface; useful for sharing attributes with other
      # interfaces. Any public method of {Vedeu::Interface} is available.
      #
      # @example
      #   Vedeu.interface 'my_interface' do
      #     # use the delay of another interface
      #     delay Vedeu.use('my_other_interface').delay
      #     # ...
      #   end
      #
      #   Vedeu.interface 'my_interface' do
      #     geometry do
      #       # use the width of another interface
      #       width Vedeu.use('my_other_interface').width
      #       # ...
      #     end
      #   end
      #
      #   Vedeu.use('my_other_interface').width # can be used in your code to
      #                                         # get this value
      #
      # @param value [String] The name of the interface you wish to use.
      #   Typically used when defining interfaces to share geometry.
      # @raise [ModelNotFound] The interface has not yet been defined.
      # @return [Vedeu::Interface]
      def use(value)
        if Vedeu.interfaces.registered?(value) == false
          fail ModelNotFound, "The properties of this interface (#{value}) " \
                              'cannot be used, since the interface has not ' \
                              'been defined.'
        end

        Vedeu.interfaces.find(value)
      end

    end # Use

  end # DSL

end # Vedeu

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.4.16 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.15 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.14 lib/vedeu/dsl/shared/use.rb