Class: Voom::Presenters::DSL::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/voom/presenters/dsl/definition.rb

Overview

The default dsl for ui This class is held in the container. When a request to render a UI comes in It creates a new UserInterface instance, binding it to the router and context of the request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, namespace, options, &block) ⇒ Definition

Returns a new instance of Definition.



9
10
11
12
13
14
# File 'lib/voom/presenters/dsl/definition.rb', line 9

def initialize(name, namespace, options, &block)
  @block = block
  @name = name
  @namespace = namespace
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/voom/presenters/dsl/definition.rb', line 8

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



8
9
10
# File 'lib/voom/presenters/dsl/definition.rb', line 8

def namespace
  @namespace
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/voom/presenters/dsl/definition.rb', line 8

def options
  @options
end

Instance Method Details

#buildObject



16
17
18
# File 'lib/voom/presenters/dsl/definition.rb', line 16

def build
  self
end

#expand(router:, context: {}) {|presenter| ... } ⇒ Object

Yields:

  • (presenter)


20
21
22
23
24
# File 'lib/voom/presenters/dsl/definition.rb', line 20

def expand(router: , context:{}, &block)
  presenter = UserInterface.new(router: router, context: context,  name: @name, namespace: @namespace, &@block)
  yield(presenter) if block
  presenter.expand_instance
end

#expand_child(parent:, context: {}) ⇒ Object

Used by attach



27
28
29
30
# File 'lib/voom/presenters/dsl/definition.rb', line 27

def expand_child(parent:, context: {})
  presenter = UserInterface.new(parent: parent, context: context, namespace: @namespace, &@block)
  presenter.expand_instance(freeze: false)
end