Module: Graphene::Tablize
- Included in:
- ResultSet
- Defined in:
- lib/graphene/tablizer.rb
Instance Method Summary collapse
-
#tablize(options = {}) ⇒ Object
Return the results formatted by the tablizer gem.
Instance Method Details
#tablize(options = {}) ⇒ Object
Return the results formatted by the tablizer gem. Do disable headers, pass :header => false. Set alignment with :align.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/graphene/tablizer.rb', line 4 def tablize(={}) rows = to_a # Default to including headers unless [:header] == false headers = attributes.map(&:to_s) << self.class.name.scan(/\w+$/).last.to_s.gsub(/s$/, '').capitalize rows.unshift(headers) [:header] = true end Tablizer::Table.new(rows, ) end |