Previews

No matching results.

x
1
<div data-react-class="Editor" data-react-props="{"mode":"ruby","name":"code_editor","storedValue":"# @param context: a hash containing any context information that might be required for this decision block.\n# Usually the `item_id` is passed here.\n# @return [nil, string]: the token to be used in the next block\n\ndef decide(context)\n # Context should have item_id\n item = Item.find_by(id: context[:item_id]) if context[:item_id].present?\n return nil if item.nil?\n item.forward_item_id.present? ? :forward_item : default_output_token\nend\n \ndef output_tokens\n [:forward_item, :without_forward_item]\nend\n \ndef default_output_token\n :without_forward_item\nend","readOnly":false,"className":"ruby-editor"}" data-react-cache-id="Editor-0" style="width:100%"></div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<%
code = "# @param context: a hash containing any context information that might be required for this decision block.
# Usually the `item_id` is passed here.
# @return [nil, string]: the token to be used in the next block
def decide(context)
# Context should have item_id
item = Item.find_by(id: context[:item_id]) if context[:item_id].present?
return nil if item.nil?
item.forward_item_id.present? ? :forward_item : default_output_token
end
def output_tokens
[:forward_item, :without_forward_item]
end
def default_output_token
:without_forward_item
end"
%>
<%= render LooposUi::CodeEditor.new(
type: "ruby",
code: code,
readonly: params[:read_only] || false
)%>
Param Description Input

Deny changes.

Show Edit button