Sha256: a5c654d12105108c179af067526f779ef7799eb0920fb6591ac7407ed9c676f5

Contents?: true

Size: 974 Bytes

Versions: 6

Compression:

Stored size: 974 Bytes

Contents

require 'vedeu/dsl/shared/all'

module Vedeu

  module DSL

    # Provides methods to be used to define views.
    #
    # @api public
    #
    class Stream

      include Vedeu::DSL
      include Vedeu::DSL::Colour
      include Vedeu::DSL::Style
      include Vedeu::DSL::Text

      # Returns an instance of DSL::Stream.
      #
      # @param model [Vedeu::Stream]
      def initialize(model, client = nil)
        @model  = model
        @client = client
      end

      # @param block [Proc]
      # @raise [InvalidSyntax] The required block was not given.
      # @return [void]
      def stream(&block)
        fail InvalidSyntax, 'block not given' unless block_given?

        model.add(model.class.build(attributes, &block))
      end

      private

      attr_reader :client, :model

      # @return [Hash]
      def attributes
        {
          client: client,
          parent: model.parent,
        }
      end

    end # Stream

  end # DSL

end # Vedeu

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vedeu-0.4.4 lib/vedeu/dsl/stream.rb
vedeu-0.4.3 lib/vedeu/dsl/stream.rb
vedeu-0.4.2 lib/vedeu/dsl/stream.rb
vedeu-0.4.1 lib/vedeu/dsl/stream.rb
vedeu-0.4.0 lib/vedeu/dsl/stream.rb
vedeu-0.3.5 lib/vedeu/dsl/stream.rb