module Typekit::Element::Persistence

Public Class Methods

included(base) click to toggle source
# File lib/typekit/element/persistence.rb, line 4
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

delete!() click to toggle source
# File lib/typekit/element/persistence.rb, line 36
def delete!
  process(:delete, id) if persistent?
  @deleted = true
  true
end
deleted?() click to toggle source
# File lib/typekit/element/persistence.rb, line 16
def deleted?
  !!@deleted
end
new?() click to toggle source
# File lib/typekit/element/persistence.rb, line 8
def new?
  id.to_s.empty?
end
persistent?() click to toggle source
# File lib/typekit/element/persistence.rb, line 12
def persistent?
  !(new? || deleted?)
end
save!() click to toggle source
# File lib/typekit/element/persistence.rb, line 20
def save!
  if new?
    element = process(:create, serialize)
  else
    element = process(:update, id, serialize)
  end
  become(element)
  true
end
update!(*arguments) click to toggle source
# File lib/typekit/element/persistence.rb, line 30
def update!(*arguments)
  assign_attributes(*arguments)
  become(process(:update, id, serialize))
  true
end