Class: Nazar::Formatter::SequelCollection

Inherits:
Object
  • Object
show all
Includes:
SequelInterface
Defined in:
lib/nazar/formatter/sequel_collection.rb

Instance Attribute Summary

Attributes included from SequelInterface

#attributes, #collection, #klass

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SequelInterface

#cells, #headers, #valid?

Constructor Details

#initialize(collection) ⇒ SequelCollection

Returns a new instance of SequelCollection.



10
11
12
13
# File 'lib/nazar/formatter/sequel_collection.rb', line 10

def initialize(collection)
  @collection = collection
  @attributes = collection.first&.values
end

Class Method Details

.valid?(data) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/nazar/formatter/sequel_collection.rb', line 15

def self.valid?(data)
  (data.is_a?(Enumerable) && data.first.is_a?(Sequel::Model)) || data.is_a?(Sequel::Dataset)
end

Instance Method Details

#summaryObject



19
20
21
# File 'lib/nazar/formatter/sequel_collection.rb', line 19

def summary
  collection.size
end