Sha256: 294e2b5b6f1d53e4fc808ac8b69566c42c502b27d36a327658cd59101424f330

Contents?: true

Size: 1.4 KB

Versions: 15

Compression:

Stored size: 1.4 KB

Contents

module Vedeu

  # A composition is a collection of interfaces.
  #
  # @api private
  class Composition

    include Vedeu::Model
    include Vedeu::Presentation

    collection Vedeu::InterfaceCollection
    member     Vedeu::Interface

    # @!attribute [r] attributes
    # @return [Hash]
    attr_reader :attributes

    # 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)

      @interfaces = @attributes[:interfaces]
    end

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

    # @return [Vedeu::InterfaceCollection]
    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: [],
        repository: Vedeu.interfaces,
        style:      nil,
      }
    end

  end # Composition

end # Vedeu

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
vedeu-0.4.55 lib/vedeu/models/composition.rb
vedeu-0.4.54 lib/vedeu/models/composition.rb
vedeu-0.4.53 lib/vedeu/models/composition.rb
vedeu-0.4.52 lib/vedeu/models/composition.rb
vedeu-0.4.51 lib/vedeu/models/composition.rb
vedeu-0.4.50 lib/vedeu/models/composition.rb
vedeu-0.4.49 lib/vedeu/models/composition.rb
vedeu-0.4.48 lib/vedeu/models/composition.rb
vedeu-0.4.47 lib/vedeu/models/composition.rb
vedeu-0.4.46 lib/vedeu/models/composition.rb
vedeu-0.4.45 lib/vedeu/models/composition.rb
vedeu-0.4.44 lib/vedeu/models/composition.rb
vedeu-0.4.43 lib/vedeu/models/composition.rb
vedeu-0.4.42 lib/vedeu/models/composition.rb
vedeu-0.4.41 lib/vedeu/models/composition.rb