Sha256: d1c7458b30257b1575949ae0ed5d537aca90ba19b106ca4324c3e6abf61b4977

Contents?: true

Size: 1.47 KB

Versions: 15

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

15 entries across 15 versions & 1 rubygems

Version Path
vedeu-0.4.13 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.12 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.11 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.10 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.9 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.8 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.7 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.6 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.5 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.4 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.3 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.2 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.1 lib/vedeu/dsl/shared/use.rb
vedeu-0.4.0 lib/vedeu/dsl/shared/use.rb
vedeu-0.3.5 lib/vedeu/dsl/shared/use.rb