Sha256: a43004deea81b4e1ed632c3afba8b36908ad68df05d4294d9f1e0c730040dcf6

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 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 Vedeu::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 [Vedeu::Interfaces]
    def add(child)
      @interfaces = interfaces.add(child)
    end

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

    # Composition objects do not have a parent.
    #
    # @return [NilClass]
    def parent
      nil
    end

    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

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.4.15 lib/vedeu/models/composition.rb
vedeu-0.4.14 lib/vedeu/models/composition.rb