Sha256: 9c9dc3e413d962f217a60386d3cd4f1892223d9d4d075be2b602f4b31250c2af

Contents?: true

Size: 1.75 KB

Versions: 19

Compression:

Stored size: 1.75 KB

Contents

module Vedeu

  module Views

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

      include Vedeu::Repositories::Model
      include Vedeu::Presentation

      collection Vedeu::Views::ViewCollection
      member     Vedeu::Views::View

      # @!attribute [r] parent
      # @return [NilClass] Composition objects do not have a parent.
      attr_reader :parent

      # Returns a new instance of Vedeu::Views::Composition.
      #
      # @param attributes [Hash]
      # @option attributes client [void]
      # @option attributes colour [Vedeu::Colours::Colour]
      # @option attributes style [Vedeu::Presentation::Style]
      # @option attributes value [Vedeu::Views::ViewCollection]
      # @return [Vedeu::Views::Composition]
      def initialize(attributes = {})
        defaults.merge!(attributes).each do |key, value|
          instance_variable_set("@#{key}", value)
        end
      end

      # @param child [Vedeu::Views::View]
      # @return [Vedeu::Views::ViewCollection]
      def add(child)
        @value = value.add(child)
      end
      alias_method :<<, :add

      # @return [Hash]
      def attributes
        {
          client: @client,
          colour: @colour,
          parent: @parent,
          style:  @style,
          value:  value,
        }
      end

      # @return [Vedeu::Views::ViewCollection]
      def value
        collection.coerce(@value, self)
      end
      alias_method :views, :value

      private

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

    end # Composition

  end # Views

end # Vedeu

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
vedeu-0.6.47 lib/vedeu/models/views/composition.rb
vedeu-0.6.46 lib/vedeu/models/views/composition.rb
vedeu-0.6.45 lib/vedeu/models/views/composition.rb
vedeu-0.6.44 lib/vedeu/models/views/composition.rb
vedeu-0.6.43 lib/vedeu/models/views/composition.rb
vedeu-0.6.42 lib/vedeu/models/views/composition.rb
vedeu-0.6.41 lib/vedeu/models/views/composition.rb
vedeu-0.6.40 lib/vedeu/models/views/composition.rb
vedeu-0.6.39 lib/vedeu/models/views/composition.rb
vedeu-0.6.38 lib/vedeu/models/views/composition.rb
vedeu-0.6.37 lib/vedeu/models/views/composition.rb
vedeu-0.6.36 lib/vedeu/models/views/composition.rb
vedeu-0.6.35 lib/vedeu/models/views/composition.rb
vedeu-0.6.34 lib/vedeu/models/views/composition.rb
vedeu-0.6.33 lib/vedeu/models/views/composition.rb
vedeu-0.6.32 lib/vedeu/models/views/composition.rb
vedeu-0.6.31 lib/vedeu/models/views/composition.rb
vedeu-0.6.30 lib/vedeu/models/views/composition.rb
vedeu-0.6.29 lib/vedeu/models/views/composition.rb