Sha256: 7652eed0cc752bbf70f62adc3cca17fc205ddebdf1bb8ac1701da387d8130942

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

module Vedeu

  module DSL

    # Provides methods to be used to define views.
    #
    class Stream

      include Vedeu::DSL
      include Vedeu::DSL::Presentation
      include Vedeu::DSL::Text

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

      # @param block [Proc]
      # @raise [Vedeu::Error::RequiresBlock]
      # @return [void]
      def stream(&block)
        fail Vedeu::Error::RequiresBlock unless block_given?

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

      private

      # Returns the default attributes for the new model.
      #
      # Overrides {Vedeu::DSL#attributes}.
      #
      # @return [Hash]
      def attributes
        {
          client: client,
          parent: model.parent,
        }
      end

    end # Stream

  end # DSL

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.6.20 lib/vedeu/dsl/stream.rb
vedeu-0.6.19 lib/vedeu/dsl/stream.rb
vedeu-0.6.18 lib/vedeu/dsl/stream.rb
vedeu-0.6.17 lib/vedeu/dsl/stream.rb
vedeu-0.6.16 lib/vedeu/dsl/stream.rb
vedeu-0.6.15 lib/vedeu/dsl/stream.rb
vedeu-0.6.14 lib/vedeu/dsl/stream.rb
vedeu-0.6.13 lib/vedeu/dsl/stream.rb