Sha256: 2a632000c9a3470d154c898a7a7ae5f58d793266b55162ecc75fd7d467ecd026

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

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]
      # @param client [Object]
      # @return [Vedeu::DSL::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

      # @return [Object]
      attr_reader :client

      # @return [Stream]
      attr_reader :model

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

    end # Stream

  end # DSL

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.4.5 lib/vedeu/dsl/stream.rb