Module: Vedeu::DSL::Use

Extended by:
Use
Included in:
Geometry, Interface, Use
Defined in:
lib/vedeu/dsl/shared/use.rb

Overview

Provides helper methods for building views.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.use(value) ⇒ Vedeu::Interface

Use the specified interface; useful for sharing attributes with other interfaces. Any public method of Interface is available.

Examples:

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

Parameters:

  • value (String)

    The name of the interface you wish to use. Typically used when defining interfaces to share geometry.

Returns:

Raises:

  • (ModelNotFound)

    The interface has not yet been defined.



36
37
38
39
40
41
42
43
44
# File 'lib/vedeu/dsl/shared/use.rb', line 36

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

Instance Method Details

#use(value) ⇒ Vedeu::Interface

Use the specified interface; useful for sharing attributes with other interfaces. Any public method of Interface is available.

Examples:

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

Parameters:

  • value (String)

    The name of the interface you wish to use. Typically used when defining interfaces to share geometry.

Returns:

Raises:

  • (ModelNotFound)

    The interface has not yet been defined.



36
37
38
39
40
41
42
43
44
# File 'lib/vedeu/dsl/shared/use.rb', line 36

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