Skip to content

Instantly share code, notes, and snippets.

@jcoyne
Created May 14, 2013 15:59
Show Gist options
  • Save jcoyne/5577116 to your computer and use it in GitHub Desktop.
Save jcoyne/5577116 to your computer and use it in GitHub Desktop.
module Hyhull
module Datastream
class WorkflowProperties < ActiveFedora::OmDatastream
set_terminology do |t|
t.root(:path=>"fields")
t.depositor
t.depositorEmail
t.collection
t.resource_state
end
# Generates an empty contentMetadata
def self.xml_template
builder = Nokogiri::XML::Builder.new do |xml|
xml.fields {}
end
return builder.doc
end
end
end
end
class UketdObject < ActiveFedora::Base
has_metadata "properties", label: "Workflow properties", type: Hyhull::Datastream::WorkflowProperties
delegate :resource_state, to: "properties"
state_machine :resource_state, :initial => :proto, :namespace => 'resource' do
event :submit, human_name: "Submit resource to QA" do
transition :proto => :qa
end
event :publish, human_name: "Publish resource" do
transition :qa => :published
end
event :hide, human_name: "Hide resource" do
transition :published => :hidden
end
event :delete, human_name: "Delete resource" do
transition [:published, :hidden] => :deleted
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment