Module: Engine2::ActionAPISupport

Instance Method Summary collapse

Instance Method Details

#configObject



248
249
250
# File 'lib/engine2/action.rb', line 248

def config
    @meta[:config] ||= {}
end

#decorate(list) ⇒ Object



263
264
265
266
267
# File 'lib/engine2/action.rb', line 263

def decorate list
    list.each do |f|
        fields(f)[:loc] ||= LOCS[f.to_sym]
    end
end

#field_filter(*flds, filter) ⇒ Object



281
282
283
# File 'lib/engine2/action.rb', line 281

def field_filter *flds, filter
    fields! *flds, filter: filter
end

#fields(field) ⇒ Object



244
245
246
# File 'lib/engine2/action.rb', line 244

def fields field
    (@meta[:fields] ||= {})[field.to_sym] ||= {}
end

#fields!(*fields, options) ⇒ Object

Raises:



252
253
254
255
256
257
# File 'lib/engine2/action.rb', line 252

def fields! *fields, options
    raise E2Error.new("No fields given to info") if fields.empty?
    fields.each do |field|
        fields(field).merge! options # rmerge ?
    end
end

#hide_fields(*flds) ⇒ Object



273
274
275
# File 'lib/engine2/action.rb', line 273

def hide_fields *flds
    fields! *flds, hidden: true
end

#loc!(hash) ⇒ Object



259
260
261
# File 'lib/engine2/action.rb', line 259

def loc! hash
    (@meta[:loc] ||= {}).merge! hash
end

#render(field, options) ⇒ Object



269
270
271
# File 'lib/engine2/action.rb', line 269

def render field, options
    fields! field, render: options
end

#show_fields(*flds) ⇒ Object



277
278
279
# File 'lib/engine2/action.rb', line 277

def show_fields *flds
    fields! *flds, hidden: false
end