Sha256: 66fb6e6879fe3e5e076dee360a88e8ee20b15bf078c70a8f877f97a240484208
Contents?: true
Size: 517 Bytes
Versions: 5
Compression:
Stored size: 517 Bytes
Contents
module Drafting module ClassMethods def from_draft(draft_or_id) draft = draft_or_id.is_a?(Draft) ? draft_or_id : Draft.find(draft_or_id) raise ArgumentError unless draft.target_type == name target = draft.target_type.constantize.new target.load_from_draft(draft.data) target.send("#{draft_parent}=", draft.parent) if draft_parent target.draft_id = draft.id target end def drafts(user) Draft.where(:user => user, :target_type => name) end end end
Version data entries
5 entries across 5 versions & 1 rubygems