Sha256: 2fded08a8d6c18c817352cef0c4c28411bbec687810dac53d26a0b3428f9e8e1

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

require 'vedeu/dsl/composition'
require 'vedeu/repositories/all'
require 'vedeu/output/presentation'
require 'vedeu/support/common'

module Vedeu

  # A composition is a collection of interfaces.
  #
  class Composition

    include Vedeu::Model
    include Vedeu::Presentation

    collection Vedeu::Interfaces
    member     Vedeu::Interface

    # Returns a new instance of Composition.
    #
    # @param attributes [Hash]
    # @option attributes colour [Vedeu::Colour]
    # @option attributes interfaces []
    # @option attributes style [Vedeu::Style]
    # @return [Composition]
    def initialize(attributes = {})
      @attributes = defaults.merge!(attributes)

      @colour     = @attributes[:colour]
      @interfaces = @attributes[:interfaces]
      @repository = Vedeu.interfaces
      @style      = @attributes[:style]
    end

    # @param child [Vedeu::Interface]
    # @return [void]
    def add(child)
      @interfaces = interfaces.add(child)
    end

    # @return [Vedeu::Interfaces]
    def interfaces
      collection.coerce(@interfaces, self)
    end
    alias_method :value, :interfaces

    private

    # The default values for a new instance of this class.
    #
    # @return [Hash]
    def defaults
      {
        client:     nil,
        colour:     nil,
        interfaces: [],
        style:      nil,
      }
    end

  end # Composition

end # Vedeu

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.4.9 lib/vedeu/models/composition.rb
vedeu-0.4.8 lib/vedeu/models/composition.rb
vedeu-0.4.7 lib/vedeu/models/composition.rb
vedeu-0.4.6 lib/vedeu/models/composition.rb