Sha256: d7673f3cac06af987de648ce41281f0b3526a3f1f85b8f8391f7afe50aac2dbd

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 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::InvalidSyntax] The required block was not given.
      # @return [void]
      def stream(&block)
        fail Vedeu::Error::InvalidSyntax, 'block not given' 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

9 entries across 9 versions & 1 rubygems

Version Path
vedeu-0.6.10 lib/vedeu/dsl/stream.rb
vedeu-0.6.9 lib/vedeu/dsl/stream.rb
vedeu-0.6.8 lib/vedeu/dsl/stream.rb
vedeu-0.6.7 lib/vedeu/dsl/stream.rb
vedeu-0.6.6 lib/vedeu/dsl/stream.rb
vedeu-0.6.5 lib/vedeu/dsl/stream.rb
vedeu-0.6.4 lib/vedeu/dsl/stream.rb
vedeu-0.6.3 lib/vedeu/dsl/stream.rb
vedeu-0.6.2 lib/vedeu/dsl/stream.rb