Sha256: 701af01d6df27310b7b74eb7791060ccbe1e3d4d244718be8a1cb7197cc73d64

Contents?: true

Size: 505 Bytes

Versions: 3

Compression:

Stored size: 505 Bytes

Contents

module CouchPotato
  module Attachments
    def self.included(base)
      base.class_eval do
        attr_accessor :_attachments
        base.extend ClassMethods
      end
    end
    
    def to_hash
      if _attachments
        super.merge('_attachments' => _attachments)
      else
        super
      end
    end
    
    module ClassMethods
      def json_create(json)
        instance = super
        instance._attachments = json['_attachments'] if json
        instance
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
langalex-couch_potato-0.2.11 lib/couch_potato/persistence/attachments.rb
langalex-couch_potato-0.2.12 lib/couch_potato/persistence/attachments.rb
langalex-couch_potato-0.2.9 lib/couch_potato/persistence/attachments.rb