Class: Vedeu::DSL::Stream

Inherits:
Object
  • Object
show all
Includes:
Vedeu::DSL, Presentation, Text
Defined in:
lib/vedeu/dsl/stream.rb

Overview

Provides methods to be used to define views.

Instance Attribute Summary

Attributes included from Vedeu::DSL

#client, #model

Instance Method Summary collapse

Methods included from Text

#text

Methods included from Presentation

#background, #colour, #colour_attributes, #foreground, #style

Methods included from Vedeu::DSL

#method_missing

Constructor Details

#initialize(model, client = nil) ⇒ Vedeu::DSL::Stream

Returns an instance of Vedeu::DSL::Stream.

Parameters:



18
19
20
21
# File 'lib/vedeu/dsl/stream.rb', line 18

def initialize(model, client = nil)
  @model  = model
  @client = client
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Vedeu::DSL

Instance Method Details

#attributesHash (private)

Returns the default attributes for the new model.

Overrides Vedeu::DSL#attributes.

Returns:

  • (Hash)


39
40
41
42
43
44
# File 'lib/vedeu/dsl/stream.rb', line 39

def attributes
  {
    client: client,
    parent: model.parent,
  }
end

#stream(&block) ⇒ void

This method returns an undefined value.

Parameters:

  • block (Proc)

Raises:



26
27
28
29
30
# File 'lib/vedeu/dsl/stream.rb', line 26

def stream(&block)
  fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given?

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