Class: Hokusai::Blocks::Variable

Inherits:
Hokusai::Block show all
Defined in:
ui/src/hokusai/blocks/variable.rb

Instance Attribute Summary

Attributes inherited from Hokusai::Block

#node, #provides, #publisher

Instance Method Summary collapse

Methods inherited from Hokusai::Block

#children, #children?, compile, computed, computed!, #draw, #draw_with, #dump, #emit, #initialize, inject, inject!, #method_missing, mount, #on_resize, provide, provides, style, styles_get, template, template_from_file, template_get, #update, use, uses

Constructor Details

This class inherits a constructor from Hokusai::Block

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hokusai::Block

Instance Method Details

#after_updatedObject



11
12
13
14
15
16
17
18
# File 'ui/src/hokusai/blocks/variable.rb', line 11

def after_updated
  if @last_height != children[0].node.meta.get_prop(:height)
    @last_height = children[0].node.meta.get_prop(:height)

    node.meta.set_prop(:height, @last_height)
    emit("height_updated", @last_height)
  end
end

#on_mountedObject

Raises:



20
21
22
23
24
25
26
# File 'ui/src/hokusai/blocks/variable.rb', line 20

def on_mounted
  klass = eval(script)

  raise Hokusai::Error.new("Class #{klass} is not a Hokusai::Block") unless klass.ancestors.include?(Hokusai::Block)

  node.meta.set_child(0, klass.mount)
end

#render(canvas) ⇒ Object



28
29
30
31
32
# File 'ui/src/hokusai/blocks/variable.rb', line 28

def render(canvas)
  if Hokusai.can_render(canvas)
    yield canvas
  end
end