Class: Hokusai::Meta
- Inherits:
-
Object
- Object
- Hokusai::Meta
- Defined in:
- ui/src/hokusai/meta.rb
Instance Attribute Summary collapse
-
#focused ⇒ Object
readonly
Returns the value of attribute focused.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#props ⇒ Object
readonly
Returns the value of attribute props.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#updater ⇒ Object
readonly
Returns the value of attribute updater.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(child) ⇒ Object
- #blur ⇒ Object
-
#child_delete(index) ⇒ Object
def destroy children.each do |child| child.before_destroy if child.respond_to?(:before_destroy) child.node.destroy end end.
- #children! ⇒ Object
- #children=(values) ⇒ Object
- #children? ⇒ Boolean
- #focus ⇒ Object
- #get_child(index) ⇒ Object
- #get_child?(index) ⇒ Boolean
- #get_prop(name) ⇒ Object
- #get_prop?(name) ⇒ Boolean
- #has_ast?(ast, index) ⇒ Boolean
-
#initialize ⇒ Meta
constructor
A new instance of Meta.
- #node_count ⇒ Object
- #on_update(target, &block) ⇒ Object
- #props! ⇒ Object
- #set_child(index, value) ⇒ Object
- #set_prop(name, value) ⇒ Object
- #update(block) ⇒ Object
Constructor Details
Instance Attribute Details
#focused ⇒ Object (readonly)
Returns the value of attribute focused.
5 6 7 |
# File 'ui/src/hokusai/meta.rb', line 5 def focused @focused end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
5 6 7 |
# File 'ui/src/hokusai/meta.rb', line 5 def parent @parent end |
#props ⇒ Object (readonly)
Returns the value of attribute props.
5 6 7 |
# File 'ui/src/hokusai/meta.rb', line 5 def props @props end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
5 6 7 |
# File 'ui/src/hokusai/meta.rb', line 5 def publisher @publisher end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
5 6 7 |
# File 'ui/src/hokusai/meta.rb', line 5 def target @target end |
#updater ⇒ Object (readonly)
Returns the value of attribute updater.
5 6 7 |
# File 'ui/src/hokusai/meta.rb', line 5 def updater @updater end |
Class Method Details
Instance Method Details
#<<(child) ⇒ Object
48 49 50 |
# File 'ui/src/hokusai/meta.rb', line 48 def <<(child) children! << child end |
#blur ⇒ Object
94 95 96 97 98 99 100 |
# File 'ui/src/hokusai/meta.rb', line 94 def blur @focused = false children?&.each do |child| child.node..blur end end |
#child_delete(index) ⇒ Object
def destroy
children.each do |child|
child.before_destroy if child.respond_to?(:before_destroy)
child.node.destroy
end
end
143 144 145 146 147 148 149 150 |
# File 'ui/src/hokusai/meta.rb', line 143 def child_delete(index) if child = children![index] child.before_destroy if child.respond_to?(:before_destroy) child.node.destroy children!.delete_at(index) end end |
#children! ⇒ Object
60 61 62 |
# File 'ui/src/hokusai/meta.rb', line 60 def children! @children ||= [] end |
#children=(values) ⇒ Object
38 39 40 |
# File 'ui/src/hokusai/meta.rb', line 38 def children=(values) @children = values end |
#children? ⇒ Boolean
42 43 44 45 46 |
# File 'ui/src/hokusai/meta.rb', line 42 def children? return nil if @children.nil? @children end |
#focus ⇒ Object
86 87 88 89 90 91 92 |
# File 'ui/src/hokusai/meta.rb', line 86 def focus @focused = true children?&.each do |child| child.node..focus end end |
#get_child(index) ⇒ Object
52 53 54 |
# File 'ui/src/hokusai/meta.rb', line 52 def get_child(index) children![index] end |
#get_child?(index) ⇒ Boolean
32 33 34 35 36 |
# File 'ui/src/hokusai/meta.rb', line 32 def get_child?(index) return nil if @children.nil? get_child(index) end |
#get_prop(name) ⇒ Object
80 81 82 83 84 |
# File 'ui/src/hokusai/meta.rb', line 80 def get_prop(name) @props ||= {} @props[name] end |
#get_prop?(name) ⇒ Boolean
68 69 70 71 72 |
# File 'ui/src/hokusai/meta.rb', line 68 def get_prop?(name) return nil if @props.nil? get_prop(name) end |
#has_ast?(ast, index) ⇒ Boolean
128 129 130 131 132 133 134 |
# File 'ui/src/hokusai/meta.rb', line 128 def has_ast?(ast, index) if portal = children![index]&.node&.portal return portal.ast.object_id == ast.object_id end false end |
#node_count ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'ui/src/hokusai/meta.rb', line 22 def node_count count = children?&.size || 0 children?&.each do |child| count += child.node..node_count end count end |
#on_update(target, &block) ⇒ Object
102 103 104 105 |
# File 'ui/src/hokusai/meta.rb', line 102 def on_update(target, &block) @target = target @updater = block end |
#props! ⇒ Object
64 65 66 |
# File 'ui/src/hokusai/meta.rb', line 64 def props! @props ||= {} end |
#set_child(index, value) ⇒ Object
56 57 58 |
# File 'ui/src/hokusai/meta.rb', line 56 def set_child(index, value) children![index] = value end |
#set_prop(name, value) ⇒ Object
74 75 76 77 78 |
# File 'ui/src/hokusai/meta.rb', line 74 def set_prop(name, value) @props ||= {} @props[name] = value end |
#update(block) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'ui/src/hokusai/meta.rb', line 107 def update(block) # pp props # if parent_block = parent if target_block = target if updater_block = updater # Hokusai::Pool.post do block.public_send(:before_updated) if block.respond_to?(:before_updated) updater_block.call(block, target_block, target_block) block.public_send(:after_updated) if block.respond_to?(:after_updated) # end end end # end children?&.each do |child| child.update end end |