class Dgrid::API::Item
Attributes
body[RW]
Public Class Methods
db_fields()
click to toggle source
# File lib/dgrid/api/item.rb, line 18 def self.db_fields %w(id name body source) end
new(options)
click to toggle source
Calls superclass method
# File lib/dgrid/api/item.rb, line 10 def initialize(options) parent_opts, my_opts = split_hash(options,[:name, :description]) super(parent_opts) set_members_from_hash(my_opts) @body ||= '' @incidents = nil end
pluralized()
click to toggle source
# File lib/dgrid/api/item.rb, line 22 def self.pluralized 'items' end
Public Instance Methods
create_incident(options = {}) { |incident| ... }
click to toggle source
# File lib/dgrid/api/item.rb, line 48 def create_incident(options = {}, &block) incident = Dgrid::API::Incident.new(options) workspaces.each do |workspace_id, workspace| returned_incident = workspace.add_incident(incident) incident = returned_incident if incident.new_record? workspace.subordinate_entity_to_other_entity(incident,self) end yield incident if block_given? incident end
incident_ids()
click to toggle source
# File lib/dgrid/api/item.rb, line 36 def incident_ids workspace.incident_ids_in_item(self) end
incidents()
click to toggle source
# File lib/dgrid/api/item.rb, line 40 def incidents incident_list = workspace.incidents incident_hash = {} incident_list.each { |incident| incident_hash[incident.id] = incident} return incident_ids.map { |id| incident_hash[id]} end
to_hash()
click to toggle source
# File lib/dgrid/api/item.rb, line 26 def to_hash { :name => name, :body => body } end
workspace()
click to toggle source
# File lib/dgrid/api/item.rb, line 32 def workspace workspace = workspaces.values.first # FIXME: assumes one workspace per item end