Class: Engine2::DecodeAction

Inherits:
Action show all
Includes:
ActionAPISupport, ActionModelSupport, ActionQuerySupport
Defined in:
lib/engine2/action/decode.rb

Instance Attribute Summary

Attributes inherited from Action

#assets, #invokable, #meta, #node, #static

Instance Method Summary collapse

Methods included from ActionAPISupport

#config, #decorate, #field_filter, #fields, #fields!, #hide_fields, #loc!, #render, #show_fields

Methods included from ActionModelSupport

#hide_pk, #node_defined, #show_pk, #unsupported_association

Methods included from ActionQuerySupport

#find_record, #get_query, #query, #select

Methods inherited from Action

action_type, #action_type, #arguments, #check_anonymous_action_class, #check_static_action, #define_invoke, #define_method, #dynamic?, #execute, #freeze_action, #http_method, http_method, inherit, inherited, #initialize, #invoke!, #join_keys, #lookup, #merge, #node_defined, #repeat, #request, #request_action_proc_params, #split_keys

Constructor Details

This class inherits a constructor from Engine2::Action

Instance Method Details

#decode(*fields, &blk) ⇒ Object



8
9
10
11
# File 'lib/engine2/action/decode.rb', line 8

def decode *fields, &blk
    query select(*fields), &blk
    @meta[:decode_fields] = fields
end

#post_processObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/engine2/action/decode.rb', line 21

def post_process
    if fields = @meta[:field_list]
        fields = fields - static.meta[:field_list] if dynamic?
        # no decorate here
        fields.each do |name|
            type_info = assets[:model].type_info[name] # foreign keys ?
            proc = ListRendererPostProcessors[type_info[:type]] # like... checkboxes, list_selects
            proc.(self, name, type_info) if proc
        end
    end
    # no super
end

#post_runObject



45
46
47
48
49
50
# File 'lib/engine2/action/decode.rb', line 45

def post_run
    decode(*assets[:model].primary_keys) unless @query
    @meta[:separator] = '/' unless @meta[:separator]
    super
    @meta[:primary_fields] = assets[:model].primary_keys
end

#pre_runObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/engine2/action/decode.rb', line 34

def pre_run
    super
    if assoc = assets[:assoc]
        decode = assoc[:model].type_info[assoc[:keys].first][:decode]
        if decode[:search][:multiple]
            show_max_selected 3
            loc! decode_selected: LOCS[:decode_selected]
        end
    end
end

#separator(sep) ⇒ Object



13
14
15
# File 'lib/engine2/action/decode.rb', line 13

def separator sep
    @meta[:separator] = sep
end

#show_max_selected(max) ⇒ Object



17
18
19
# File 'lib/engine2/action/decode.rb', line 17

def show_max_selected max
    @meta[:show_max_selected] = max
end