Class: Nazar::Formatter::SequelCollection
- Inherits:
-
Object
- Object
- Nazar::Formatter::SequelCollection
- 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
-
#initialize(collection) ⇒ SequelCollection
constructor
A new instance of SequelCollection.
- #summary ⇒ Object
Methods included from SequelInterface
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
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
#summary ⇒ Object
19 20 21 |
# File 'lib/nazar/formatter/sequel_collection.rb', line 19 def summary collection.size end |