Module: Nazar::Formatter::SequelInterface
- Included in:
- SequelCollection, SequelItem
- Defined in:
- lib/nazar/formatter/sequel_interface.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/nazar/formatter/sequel_interface.rb', line 6 def attributes @attributes end |
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
6 7 8 |
# File 'lib/nazar/formatter/sequel_interface.rb', line 6 def collection @collection end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
6 7 8 |
# File 'lib/nazar/formatter/sequel_interface.rb', line 6 def klass @klass end |
Instance Method Details
#cells ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nazar/formatter/sequel_interface.rb', line 16 def cells @cells ||= begin schema = collection.first.db_schema collection.map do |item| item.values.map do |column, value| CellFormatter.new(value, type: schema.dig(column, :type)).format end end end end |
#headers ⇒ Object
12 13 14 |
# File 'lib/nazar/formatter/sequel_interface.rb', line 12 def headers HeadersFormatter.new(attributes.keys).format end |
#summary ⇒ Object
28 29 30 |
# File 'lib/nazar/formatter/sequel_interface.rb', line 28 def summary collection.size end |
#valid? ⇒ Boolean
8 9 10 |
# File 'lib/nazar/formatter/sequel_interface.rb', line 8 def valid? !!attributes end |