Class: Hokusai::Mounting::MountEntry
- Inherits:
-
Object
- Object
- Hokusai::Mounting::MountEntry
- Defined in:
- ui/src/hokusai/mounting/mount_entry.rb
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #debug ⇒ Object
-
#initialize(index, ast, block, parent, target = parent, context: nil) ⇒ MountEntry
constructor
A new instance of MountEntry.
- #loop? ⇒ Boolean
- #mount(context: nil) {|child_block| ... } ⇒ Object
- #slot? ⇒ Boolean
- #virtual? ⇒ Boolean
- #with_block(new_block, supercede_parent: false) ⇒ Object
Constructor Details
#initialize(index, ast, block, parent, target = parent, context: nil) ⇒ MountEntry
Returns a new instance of MountEntry.
6 7 8 9 10 11 12 13 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 6 def initialize(index, ast, block, parent, target = parent, context: nil) @index = index @ast = ast @block = block @parent = parent @target = target @ctx = context end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
4 5 6 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 4 def ast @ast end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 4 def block @block end |
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
4 5 6 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 4 def ctx @ctx end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
4 5 6 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 4 def index @index end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 4 def parent @parent end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
4 5 6 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 4 def target @target end |
Instance Method Details
#debug ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 27 def debug StringIO.open do |io| io << "#{block.class} | #{ast.type} (#{index})\n" io << "#{block.node.ast.children.map(&:type)}" io << "parent: #{parent.class}\n" io << "target: #{target.class}\n\n" end.string end |
#loop? ⇒ Boolean
15 16 17 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 15 def loop? ast.loop? end |
#mount(context: nil) {|child_block| ... } ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 41 def mount(context: nil) klass = target.class.use(ast.type) portal = Node.new(ast) node = klass.compile(ast.type, portal) node.add_styles(target.class) node.add_props_from_block(target, context: context || ctx) child_block = klass.new(node: node) child_block.node..publisher.add(target) # todo UpdateEntry.new(child_block, block, target).register(context: context || ctx) block.class.provides.each do |k, v| if v.is_a?(Symbol) Node.provide(child_block.node, k, ->{ block.public_send(v) }) # child_block.node.meta.provides[k] = -> { block.public_send(v) } # child_block.class.provides[k] = -> { block.public_send(v) } else Node.provide(child_block.node, k, v) # child_block.node.meta.provides[k] = v # child_block.class.provides[k] = v end end block.node. << child_block yield child_block block.public_send(:on_mounted) if block.respond_to?(:on_mounted) end |
#slot? ⇒ Boolean
23 24 25 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 23 def slot? ast.slot? end |
#virtual? ⇒ Boolean
19 20 21 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 19 def virtual? ast.virtual? end |
#with_block(new_block, supercede_parent: false) ⇒ Object
36 37 38 39 |
# File 'ui/src/hokusai/mounting/mount_entry.rb', line 36 def with_block(new_block, supercede_parent: false) parent_block = supercede_parent ? block : parent MountEntry.new(index, ast, new_block, parent_block, target, context: ctx) end |