Class: Papercat::Document

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/papercat/document.rb

Direct Known Subclasses

Javascript, Page, Stylesheet, Template

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.at(pathname) ⇒ Object



4
5
6
# File 'app/models/papercat/document.rb', line 4

def self.at pathname
  find_by("data #>> '{pathname}' = ?", pathname)
end

.get(conditions) ⇒ Object



8
9
10
# File 'app/models/papercat/document.rb', line 8

def self.get conditions
  where("data @> '#{conditions.to_json}'")
end

Instance Method Details

#set(data) ⇒ Object



14
15
16
# File 'app/models/papercat/document.rb', line 14

def set data
  update(data: self.data.deep_merge(data.deep_stringify_keys))
end