Class: ExpressAdmin::DefinitionList
- Inherits:
-
ExpressTemplates::Components::Configurable
- Object
- ExpressTemplates::Components::Configurable
- ExpressAdmin::DefinitionList
- Includes:
- ExpressTemplates::Components::Capabilities::Resourceful
- Defined in:
- app/components/express_admin/definition_list.rb
Direct Known Subclasses
Instance Method Summary collapse
- #definitions ⇒ Object
- #definitions_from_array(fields) ⇒ Object
- #definitions_from_hash(hash) ⇒ Object
Instance Method Details
#definitions ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/components/express_admin/definition_list.rb', line 22 def definitions if config[:list].kind_of?(Array) definitions_from_array(config[:list]) elsif config[:list].kind_of?(Hash) definitions_from_hash(config[:list]) end end |
#definitions_from_array(fields) ⇒ Object
44 45 46 |
# File 'app/components/express_admin/definition_list.rb', line 44 def definitions_from_array(fields) Hash[fields.map {|field| ["#{field.to_s.titleize}:", "{{resource.#{field}}}"]}] end |
#definitions_from_hash(hash) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/components/express_admin/definition_list.rb', line 30 def definitions_from_hash(hash) processed = hash.map do |k,v| value = if v.kind_of? Symbol resource.send(v) elsif v.respond_to?(:call) v.call(resource).html_safe else v end [promptify(k), value] end Hash[processed] end |