Sha256: 9f9f0f31761e7555675d6cfabcc0400b9e65dc59c9b626db080a48dee708ea72

Contents?: true

Size: 524 Bytes

Versions: 13

Compression:

Stored size: 524 Bytes

Contents

module Cistern::Formatter::Default
  class << self
    def call(object)
      case object
      when Cistern::Collection
        format_collection(object)
      when Cistern::Model
        format_model(object)
      else
        object.to_s
      end
    end

    def format_model(model)
      "#{model} #{model.attributes.inspect}"
    end

    def format_collection(collection)
      "#{collection} #{collection.attributes.inspect} records=[#{collection.records.map { |m| format_model(m) }.join(', ')}]"
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cistern-2.8.0 lib/cistern/formatter/default.rb
cistern-2.7.2 lib/cistern/formatter/default.rb
cistern-2.7.1 lib/cistern/formatter/default.rb
cistern-2.7.0 lib/cistern/formatter/default.rb
cistern-2.6.0 lib/cistern/formatter/default.rb
cistern-2.5.0 lib/cistern/formatter/default.rb
cistern-2.4.1 lib/cistern/formatter/default.rb
cistern-2.4.0 lib/cistern/formatter/default.rb
cistern-2.3.0 lib/cistern/formatter/default.rb
cistern-2.2.7 lib/cistern/formatter/default.rb
cistern-2.2.6 lib/cistern/formatter/default.rb
cistern-2.2.5 lib/cistern/formatter/default.rb
cistern-2.2.4 lib/cistern/formatter/default.rb