Sha256: c6c41906c4dcfaf5f5f456b9f8ad1456c00c30869f21ed7ed206c8d5759bf566

Contents?: true

Size: 475 Bytes

Versions: 1

Compression:

Stored size: 475 Bytes

Contents

module Papercat
  class Document < ActiveRecord::Base
    
    def self.at pathname
      find_by("data #>> '{pathname}' = ?", pathname)
    end
    
    def self.get conditions
      where("data @> '#{conditions.to_json}'")
    end
    
    store_accessor :data, :pathname
    
    def set data
      update(data: self.data.deep_merge(data.deep_stringify_keys))
    end

    # def as_json options = {}
    #   super(options.update(methods: [:pathname]))
    # end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
papercat-0.0.2 app/models/papercat/document.rb