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
Instance Method Summary collapse
- #definitions ⇒ Object
- #definitions_from_array(fields) ⇒ Object
- #definitions_from_hash(hash) ⇒ Object
Instance Method Details
#definitions ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/components/express_admin/definition_list.rb', line 14 def definitions if @args.first.kind_of?(Array) definitions_from_array(@args.first) elsif @args.first.kind_of?(Hash) definitions_from_hash(@args.first) end end |
#definitions_from_array(fields) ⇒ Object
33 34 35 |
# File 'app/components/express_admin/definition_list.rb', line 33 def definitions_from_array(fields) Hash[fields.map {|field| ["#{field.to_s.titleize}:", resource.send(field)]}] end |
#definitions_from_hash(hash) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/express_admin/definition_list.rb', line 22 def definitions_from_hash(hash) processed = hash.map do |k,v| if v.kind_of? Symbol [k, resource.send(v)] else [k, v] end end Hash[processed] end |