class Nazar::Formatter::ActiveRecordCollection
Public Class Methods
new(collection)
click to toggle source
# File lib/nazar/formatter/active_record_collection.rb, line 10 def initialize(collection) @collection = collection @collection.load if @collection.respond_to?(:loaded?) && !@collection.loaded? @attributes = collection.first&.attributes @klass = collection.first&.class end
valid?(data)
click to toggle source
# File lib/nazar/formatter/active_record_collection.rb, line 18 def self.valid?(data) data.is_a?(ActiveRecord::Associations::CollectionProxy) || data.is_a?(ActiveRecord::Relation) || (data.is_a?(Enumerable) && data.first.is_a?(ActiveRecord::Base)) end
Public Instance Methods
summary()
click to toggle source
# File lib/nazar/formatter/active_record_collection.rb, line 24 def summary collection.size end