Class: TinyAdmin::Actions::BasicAction

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/tiny_admin/actions/basic_action.rb

Direct Known Subclasses

Index, Show

Instance Method Summary collapse

Methods included from Utils

#humanize, #params_to_s, #prepare_page, #to_class

Instance Method Details

#attribute_options(options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tiny_admin/actions/basic_action.rb', line 8

def attribute_options(options)
  options&.each_with_object({}) do |field, result|
    field_data =
      if field.is_a?(Hash)
        if field.one?
          field, method = field.first
          { field.to_s => { field: field.to_s, method: method } }
        else
          { field[:field] => field }
        end
      else
        { field => { field: field } }
      end
    result.merge!(field_data)
  end
end