Sha256: 56d6ee83f3074ae01c1a88ae2846f79b589f4ab666293a043f651815017f8f8e

Contents?: true

Size: 555 Bytes

Versions: 3

Compression:

Stored size: 555 Bytes

Contents

# frozen_string_literal: true

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

3 entries across 3 versions & 1 rubygems

Version Path
cistern-2.10.0 lib/cistern/formatter/default.rb
cistern-2.8.2 lib/cistern/formatter/default.rb
cistern-2.8.1 lib/cistern/formatter/default.rb