Class: Hokusai::Mounting::UpdateEntry
- Inherits:
-
Object
- Object
- Hokusai::Mounting::UpdateEntry
- Defined in:
- ui/src/hokusai/mounting/update_entry.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(block, parent, target) ⇒ UpdateEntry
constructor
A new instance of UpdateEntry.
- #meta ⇒ Object
- #register(context: nil) ⇒ Object
Constructor Details
#initialize(block, parent, target) ⇒ UpdateEntry
Returns a new instance of UpdateEntry.
6 7 8 9 10 |
# File 'ui/src/hokusai/mounting/update_entry.rb', line 6 def initialize(block, parent, target) @block = block @parent = parent @target = target end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'ui/src/hokusai/mounting/update_entry.rb', line 4 def block @block end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'ui/src/hokusai/mounting/update_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/update_entry.rb', line 4 def target @target end |
Instance Method Details
#meta ⇒ Object
12 13 14 |
# File 'ui/src/hokusai/mounting/update_entry.rb', line 12 def block.node. end |
#register(context: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'ui/src/hokusai/mounting/update_entry.rb', line 16 def register(context: nil) .on_update(target) do |ublock, uparent, utarget| if portal = ublock.node.portal portal.ast.children.each_with_index do |child, index| next unless child.has_if_condition? child_present = ->(child) do .has_ast?(child, index) end if child.if.args.size > 0 visible = utarget.public_send(child.if.method, context: context) else visible = utarget.public_send(child.if.method) end child_block_klass = target.class.use(child.type) if !!visible if child.else_condition_active? .child_delete(index) if child_present.call(child) child.else_active = 0 end unless child_present.call(child) portal = Node.new(child, Node.new(child)) node = child_block_klass.compile("root", portal) stack = [] child.children.each_with_index do |ast, ast_index| stack << MountEntry.new(ast_index, ast, ublock, uparent, utarget) end child_block = NodeMounter.new(node, child_block_klass, [stack]).mount(context: context) UpdateEntry.new(child_block, block, target).register(context: context) child_block.node.add_styles(target.class) child_block.node.add_props_from_block(target, context: context) child_block.node..publisher.add(target) .children!.insert(index, child_block) child_block.public_send(:before_updated) if child_block.respond_to?(:before_updated) child_block.update child.else_active = 0 end elsif !visible if !child.has_else_condition? || (child.has_else_condition? && !child.else_condition_active?) if (child_present.call(child)) .child_delete(index) end end if child.has_else_condition? && !child.else_condition_active? portal = Node.new(child, Node.new(child)) else_child_block_klass = target.class.use(child.else_ast.type) node = else_child_block_klass.compile(child.else_ast.type, portal) stack = [] child.else_ast.children.each_with_index do |ast, ast_index| stack << MountEntry.new(ast_index, ast, ublock, uparent, utarget) end child_block = NodeMounter.new(node, else_child_block_klass, [stack]).mount(context: context) UpdateEntry.new(child_block, block, utarget).register(context: context) child_block.node.add_styles(utarget.class) child_block.node.add_props_from_block(utarget, context: context) child_block.node..publisher.add(utarget) .children!.insert(index, child_block) child_block.public_send(:before_updated) if child_block.respond_to?(:before_updated) child_block.update child.else_active = 1 end end end end ublock.public_send(:before_updated) if ublock.respond_to?(:before_updated) ublock.node.add_props_from_block(utarget, context: context) ublock.public_send(:after_updated) if ublock.respond_to?(:after_updated) end end |