Class: Vedeu::Views::Composition

Inherits:
Object
  • Object
show all
Includes:
Presentation, Repositories::Model, Value
Defined in:
lib/vedeu/views/composition.rb

Overview

A composition is a collection of interfaces.

Instance Attribute Summary

Attributes included from Repositories::Model

#repository

Instance Method Summary collapse

Methods included from Value

included

Methods included from Presentation

#to_s

Methods included from Presentation::Styles

#name, #parent, #render_style, #style, #style=

Methods included from Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Methods included from Presentation::Position

#position, #position=, #position?, #render_position, #x, #y

Methods included from Presentation::Colour

#background, #background=, #colour, #colour=, #colour?, #foreground, #foreground=, #name, #named_colour, #named_colour?, #parent, #parent_colour, #parent_colour?, #render_colour

Methods included from Repositories::Model

included, #store

Constructor Details

#initialize(attributes = {}) ⇒ Vedeu::Views::Composition

Returns a new instance of Vedeu::Views::Composition.

Parameters:

  • attributes (Hash<Symbol => void>) (defaults to: {})

Options Hash (attributes):



35
36
37
38
39
# File 'lib/vedeu/views/composition.rb', line 35

def initialize(attributes = {})
  defaults.merge!(attributes).each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Method Details

#add(child) ⇒ Vedeu::Views::Views Also known as: <<

Adds the child to the collection.

Parameters:

Returns:



45
46
47
# File 'lib/vedeu/views/composition.rb', line 45

def add(child)
  @value = value.add(child)
end

#attributesHash<Symbol => void>

Returns:

  • (Hash<Symbol => void>)


51
52
53
54
55
56
57
58
59
# File 'lib/vedeu/views/composition.rb', line 51

def attributes
  {
    client: client,
    colour: colour,
    parent: parent,
    style:  style,
    value:  value,
  }
end

#defaultsHash<Symbol => void> (private)

The default options/attributes for a new instance of this class.

Returns:

  • (Hash<Symbol => void>)


74
75
76
77
78
79
80
81
82
# File 'lib/vedeu/views/composition.rb', line 74

def defaults
  {
    client: nil,
    colour: nil,
    parent: nil,
    style:  nil,
    value:  [],
  }
end

#update_buffers(refresh = false) ⇒ Vedeu::Views::Composition

Parameters:

  • refresh (Boolean) (defaults to: false)

    Should the buffer(s) of the view(s) in this composition be refreshed once stored? Default: false.

Returns:



65
66
67
68
69
# File 'lib/vedeu/views/composition.rb', line 65

def update_buffers(refresh = false)
  views.each { |view| view.update_buffer(refresh) } if views?

  self
end