Class: ExpressAdmin::Components::Presenters::DefinitionList
- Inherits:
-
ExpressTemplates::Components::Configurable
- Object
- ExpressTemplates::Components::Configurable
- ExpressAdmin::Components::Presenters::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
24 25 26 27 28 29 30 |
# File 'app/components/express_admin/definition_list.rb', line 24 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
46 47 48 |
# File 'app/components/express_admin/definition_list.rb', line 46 def definitions_from_array(fields) Hash[fields.map {|field| ["#{field.to_s.titleize}:", "{{resource.#{field}}}"]}] end |
#definitions_from_hash(hash) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/components/express_admin/definition_list.rb', line 32 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 |