Sha256: ba6f4ce0094f298a9189757ae813bbc7928889df70192a5bcca0342ca73f8e60

Contents?: true

Size: 645 Bytes

Versions: 1

Compression:

Stored size: 645 Bytes

Contents

if defined?(::AwesomePrint)
  module ::AwesomePrint::ContractValueObject
    def self.included(base)
      base.send :alias_method, :cast_without_cvo, :cast
      base.send :alias_method, :cast, :cast_with_cvo
    end

    def cast_with_cvo(object, type)
      cast = cast_without_cvo(object, type)
      if (defined?(::ContractValueObject)) && (object.is_a?(::ContractValueObject))
        cast = :contract_value_object
      end
      cast
    end

    def awesome_contract_value_object(object)
      "#{object.class} #{awesome_hash(object.to_h)}"
    end
  end

  AwesomePrint::Formatter.send(:include, AwesomePrint::ContractValueObject)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contract_value_object-0.1.0 lib/contract_value_object/awesome_print.rb