Class: Engine2::DecodeMeta
Instance Attribute Summary
Attributes inherited from Meta
#action, #assets, #invokable, #static
Instance Method Summary
collapse
#config, #decorate, #field_filter, #hide_fields, #info, #info!, #loc!, #reload_routes!, #render, #show_fields
#action_defined, #get_type_info, #hide_pk, #show_pk, #unsupported_association
#get_query, #query, #select
Methods inherited from Meta
#action_defined, #check_static_meta, #dynamic?, #freeze_meta, #get, http_method, #http_method, inherited, #initialize, #invoke!, #lookup, #merge, #meta_type, meta_type, #request, #request_meta_proc_params, #response, #split_keys
Constructor Details
This class inherits a constructor from Engine2::Meta
Instance Method Details
#decode(*fields, &blk) ⇒ Object
7
8
9
10
|
# File 'lib/engine2/meta/decode_meta.rb', line 7
def decode *fields, &blk
query select(*fields), &blk
@meta[:decode_fields] = fields
end
|
#post_process ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/engine2/meta/decode_meta.rb', line 20
def post_process
if fields = @meta[:fields]
fields = fields - static.get[:fields] if dynamic?
fields.each do |name|
type_info = assets[:model].type_info[name]
proc = ListRendererPostProcessors[type_info[:type]]
proc.(self, name, type_info) if proc
end
end
end
|
44
45
46
47
48
49
|
# File 'lib/engine2/meta/decode_meta.rb', line 44
def post_run
query select(*assets[:model].primary_keys) unless @query
@meta[:separator] = '/' unless @meta[:separator]
super
@meta[:primary_fields] = assets[:model].primary_keys
end
|
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/engine2/meta/decode_meta.rb', line 33
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
@meta[:decode_selected] = LOCS[:decode_selected]
end
end
end
|
#separator(sep) ⇒ Object
12
13
14
|
# File 'lib/engine2/meta/decode_meta.rb', line 12
def separator sep
@meta[:separator] = sep
end
|
#show_max_selected(max) ⇒ Object
16
17
18
|
# File 'lib/engine2/meta/decode_meta.rb', line 16
def show_max_selected max
@meta[:show_max_selected] = max
end
|