module AwesomePrint::Cistern

Public Class Methods

included(base) click to toggle source
# File lib/cistern/formatter/awesome_print.rb, line 12
def self.included(base)
  base.send :alias_method, :cast_without_cistern, :cast
  base.send :alias_method, :cast, :cast_with_cistern
end

Public Instance Methods

awesome_cistern_collection(object) click to toggle source

Format Cistern::Model

# File lib/cistern/formatter/awesome_print.rb, line 40
def awesome_cistern_collection(object)
  "#{object.class.name} #{awesome_hash(attributes: object.attributes, records: object.to_a)}"
end
awesome_cistern_model(object) click to toggle source

Format Cistern::Model

# File lib/cistern/formatter/awesome_print.rb, line 31
def awesome_cistern_model(object)
  data = object.attributes.keys.sort.each_with_object({}) do |e, a|
    a[e] = object.read_attribute(e)
  end
  "#{object} #{awesome_hash(data)}"
end
cast_with_cistern(object, type) click to toggle source
# File lib/cistern/formatter/awesome_print.rb, line 17
def cast_with_cistern(object, type)
  cast = cast_without_cistern(object, type)
  if object.is_a?(Cistern::Model)
    cast = :cistern_model
  elsif object.is_a?(Cistern::Singular)
    cast = :cistern_model
  elsif object.is_a?(Cistern::Collection)
    cast = :cistern_collection
  end
  cast
end