Class: OpenWFE::AttributeExpression

Inherits:
FlowExpression show all
Defined in:
lib/openwfe/expressions/fe_fqv.rb

Overview

The ‘a’ or ‘attribute’ expression. Directly describing some variable or list content in XML or in YAML.

_set :field => "list" do
    _a """
        <list>
            <string>a</string>
            <string>b</string>
            <string>c</string>
        </list>
    """
end

or

_set :field => "list" do
    _attribute """
--- 
- a
- b
- c
    """
 end

Note that it’s actually easier to write :

_set :filed => "list" do
    reval "[ 'a', 'b', 'c' ]"
end

but it’s less secure.

Instance Attribute Summary

Attributes inherited from FlowExpression

#apply_time, #attributes, #children, #environment_id, #fei, #parent_id, #raw_representation

Attributes included from Contextual

#application_context

Instance Method Summary collapse

Methods inherited from FlowExpression

#cancel, #clean_children, #delete_variable, #dup_environment, #fetch_environment, #fetch_text_content, #get_binding, #get_environment, #get_parent, #get_root_environment, #has_attribute, #initialize, is_definition, is_definition?, #lookup_attribute, #lookup_attributes, #lookup_boolean_attribute, #lookup_comma_list_attribute, #lookup_downcase_attribute, #lookup_ref, #lookup_string_attribute, #lookup_sym_attribute, #lookup_value, #lookup_variable, #lookup_vf_attribute, names, #new_environment, new_exp, #owns_its_environment?, #paused?, #remove_child, #reply, #reply_to_parent, #set_variable, #store_itself, #synchronize, #to_s, #to_yaml_properties

Methods included from Contextual

#get_work_directory, #init_service, #lookup

Methods included from Logging

#ldebug, #ldebug_callstack, #lerror, #lfatal, #linfo, #llog, #lunknown, #lwarn

Methods included from OwfeServiceLocator

#get_engine, #get_error_journal, #get_expool, #get_expression_map, #get_expression_pool, #get_expression_storage, #get_expression_storages, #get_journal, #get_participant_map, #get_scheduler, #get_wfid_generator

Methods inherited from ObjectWithMeta

#class_def, meta_def, meta_eval, metaclass

Constructor Details

This class inherits a constructor from OpenWFE::FlowExpression

Instance Method Details

#apply(workitem) ⇒ Object



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/openwfe/expressions/fe_fqv.rb', line 156

def apply workitem

    #text = fetch_text_content workitem
    #text = text.strip
    #result = if text[0, 3] == "---"
    #    YAML.load text
    #else
    #    d = REXML::Document.new text
    #    XmlCodec::decode_attribute d.root
    #end

    child = @children.first

    text = if child.is_a?(String)

        child

    elsif child.is_a?(FlowExpressionId)

        exp = get_expression_pool.fetch_expression child
        ExpressionTree.to_s exp.raw_representation

    else

        child.to_s
    end

    text = text.strip

    result = if text[0, 3] == '---'
        YAML.load text
    else
        d = REXML::Document.new text
        XmlCodec::decode_attribute d.root
    end

    workitem.set_result(result) if result != nil

    reply_to_parent workitem
end