Class: ExpressAdmin::DefinitionTable
- Inherits:
-
ExpressTemplates::Components::Configurable
- Object
- ExpressTemplates::Components::Configurable
- ExpressAdmin::DefinitionTable
- Includes:
- ExpressTemplates::Components::Capabilities::Resourceful
- Defined in:
- app/components/express_admin/definition_table.rb
Instance Method Summary collapse
- #definitions ⇒ Object
- #definitions_from_array(fields) ⇒ Object
- #definitions_from_hash(hash) ⇒ Object
Instance Method Details
#definitions ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/components/express_admin/definition_table.rb', line 18 def definitions if @args.nil? definitions_from_hash(config) elsif @args.first.try(:kind_of?, Array) definitions_from_array(@args.first) end end |
#definitions_from_array(fields) ⇒ Object
37 38 39 |
# File 'app/components/express_admin/definition_table.rb', line 37 def definitions_from_array(fields) Hash[fields.map {|field| ["#{field.to_s.titleize}:", "{{resource.#{field}}}"]}] end |
#definitions_from_hash(hash) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/express_admin/definition_table.rb', line 26 def definitions_from_hash(hash) processed = hash.map do |k,v| if v.kind_of? Symbol [promptify(k), resource.send(v)] else [promptify(k), helpers.instance_eval("(#{v.source}).call(resource).to_s").html_safe] end end Hash[processed] end |