Module: AwesomePrint::Cistern
- Defined in:
- lib/cistern/formatter/awesome_print.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#awesome_cistern_collection(object) ⇒ Object
Format Cistern::Model ——————————————————————————.
-
#awesome_cistern_model(object) ⇒ Object
Format Cistern::Model ——————————————————————————.
- #cast_with_cistern(object, type) ⇒ Object
Class Method Details
.included(base) ⇒ Object
12 13 14 15 |
# 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 |
Instance Method Details
#awesome_cistern_collection(object) ⇒ Object
Format Cistern::Model
40 41 42 |
# 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) ⇒ Object
Format Cistern::Model
31 32 33 34 35 36 |
# 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) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# 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 |