Class: Objs::Partial
- Inherits:
-
Gloo::Core::Obj
- Object
- Gloo::Core::Obj
- Objs::Partial
- Defined in:
- lib/objs/partial.rb
Constant Summary collapse
- KEYWORD =
'partial'.freeze
- KEYWORD_SHORT =
'part'.freeze
- ON_RENDER =
Events
'on_render'.freeze
- AFTER_RENDER =
'after_render'.freeze
- PARAMS =
Parameters used during render.
'params'.freeze
- CONTENT =
Content
'content'.freeze
Class Method Summary collapse
-
.messages ⇒ Object
Get a list of message names that this object receives.
-
.short_typename ⇒ Object
The short name of the object type.
-
.typename ⇒ Object
The name of the object type.
Instance Method Summary collapse
-
#add_children_on_create? ⇒ Boolean
Does this object have children to add when an object is created in interactive mode? This does not apply during obj load, etc.
-
#add_default_children ⇒ Object
Add children to this object.
-
#content ⇒ Object
Get the content obj.
-
#msg_render ⇒ Object
Get the expiration date for the certificate.
-
#multiline_value? ⇒ Boolean
Does this object support multi-line values? Initially only true for scripts.
-
#params_hash ⇒ Object
Get the params hash from the child object.
-
#render(render_ƒ = :render_html) ⇒ Object
Render the page.
-
#render_layout(head, body) ⇒ Object
Render the layout with the body and head params.
-
#run_after_render ⇒ Object
Run the on rendered script if there is one.
-
#run_on_render ⇒ Object
Run the on render script if there is one.
-
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
Class Method Details
.messages ⇒ Object
Get a list of message names that this object receives.
138 139 140 |
# File 'lib/objs/partial.rb', line 138 def self. return super + [ 'render' ] end |
.short_typename ⇒ Object
The short name of the object type.
34 35 36 |
# File 'lib/objs/partial.rb', line 34 def self.short_typename return KEYWORD_SHORT end |
.typename ⇒ Object
The name of the object type.
27 28 29 |
# File 'lib/objs/partial.rb', line 27 def self.typename return KEYWORD end |
Instance Method Details
#add_children_on_create? ⇒ Boolean
Does this object have children to add when an object is created in interactive mode? This does not apply during obj load, etc.
111 112 113 |
# File 'lib/objs/partial.rb', line 111 def add_children_on_create? return true end |
#add_default_children ⇒ Object
Add children to this object. This is used by containers to add children needed for default configurations.
120 121 122 123 124 125 126 127 128 |
# File 'lib/objs/partial.rb', line 120 def add_default_children fac = @engine.factory fac.create_script ON_RENDER, '', self fac.create_script AFTER_RENDER, '', self fac.create_can PARAMS, self fac.create_can CONTENT, self end |
#content ⇒ Object
Get the content obj.
56 57 58 |
# File 'lib/objs/partial.rb', line 56 def content return find_child CONTENT end |
#msg_render ⇒ Object
Get the expiration date for the certificate.
145 146 147 148 149 |
# File 'lib/objs/partial.rb', line 145 def msg_render part_content = self.render @engine.heap.it.set_to part_content return part_content end |
#multiline_value? ⇒ Boolean
Does this object support multi-line values? Initially only true for scripts.
49 50 51 |
# File 'lib/objs/partial.rb', line 49 def multiline_value? return false end |
#params_hash ⇒ Object
Get the params hash from the child object. Returns nil if there is none.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/objs/partial.rb', line 64 def params_hash params_can = find_child PARAMS return nil unless params_can h = {} params_can.children.each do |o| h[ o.name ] = o.value end return h end |
#render(render_ƒ = :render_html) ⇒ Object
Render the page. Use the specified render function or HTML by default.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/objs/partial.rb', line 160 def render( render_ |
#render_layout(head, body) ⇒ Object
Render the layout with the body and head params.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/objs/partial.rb', line 183 def render_layout( head, body ) run_on_render part_content = '' content.children.each do |e| e = Gloo::Objs::Alias.resolve_alias( @engine, e ) obj = e.find_child CONTENT e = obj if obj part_content << Element.render_obj( e, :render_html, @engine ) end params = params_hash || {} params[ 'head' ] = head params[ 'body' ] = body # part_content = Page.render_params part_content, params part_content = @engine.running_app.obj..render part_content, params run_after_render return part_content end |
#run_after_render ⇒ Object
Run the on rendered script if there is one.
94 95 96 97 98 99 |
# File 'lib/objs/partial.rb', line 94 def run_after_render o = find_child AFTER_RENDER return unless o Gloo::Exec::Dispatch.( @engine, 'run', o ) end |
#run_on_render ⇒ Object
Run the on render script if there is one.
84 85 86 87 88 89 |
# File 'lib/objs/partial.rb', line 84 def run_on_render o = find_child ON_RENDER return unless o Gloo::Exec::Dispatch.( @engine, 'run', o ) end |
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
41 42 43 |
# File 'lib/objs/partial.rb', line 41 def set_value( new_value ) self.value = new_value.to_s end |