class Dgrid::API::Entity
Attributes
description[RW]
id[RW]
workspaces[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/dgrid/api/entity.rb, line 11 def initialize(options) @id = nil set_members_from_hash(options) # FIXME Remove this when ArgumentValidation::option is implemented @description ||= '' @workspaces = {} end
pluralized()
click to toggle source
# File lib/dgrid/api/entity.rb, line 58 def self.pluralized 'entities' end
singular()
click to toggle source
# File lib/dgrid/api/entity.rb, line 29 def self.singular name.split('::').last.downcase end
type()
click to toggle source
# File lib/dgrid/api/entity.rb, line 21 def self.type self.name.split('::').last end
Public Instance Methods
add_entity(entity)
click to toggle source
# File lib/dgrid/api/entity.rb, line 62 def add_entity(entity) workspaces.each do |workspace_id,workspace| # STDERR.puts "adding #{entity.type} #{entity} to #{self.type} #{self} in workspace #{workspace}" if entity.in_workspace?(workspace) workspace.subordinate_entity_to_other_entity(entity, self) end end end
add_workspace(workspace)
click to toggle source
# File lib/dgrid/api/entity.rb, line 45 def add_workspace(workspace) @workspaces[workspace.id] = workspace self end
attach(filename)
click to toggle source
# File lib/dgrid/api/entity.rb, line 71 def attach(filename) conn = connection # TODO Adapt this to a workspace-independent model when available in the server conn.attach_file_to_entity_in_workspace(self,filename,first_workspace.id) end
connection()
click to toggle source
# File lib/dgrid/api/entity.rb, line 77 def connection first_workspace.connection end
first_workspace()
click to toggle source
# File lib/dgrid/api/entity.rb, line 81 def first_workspace workspaces.values.first end
in_workspace?(workspace)
click to toggle source
# File lib/dgrid/api/entity.rb, line 41 def in_workspace?(workspace) return @workspaces.include?(workspace.id) end
link_to(other, options = {})
click to toggle source
# File lib/dgrid/api/entity.rb, line 36 def link_to(other, options = {}) raise UnimplementedFunctionality self end
new_record?()
click to toggle source
# File lib/dgrid/api/entity.rb, line 54 def new_record? @id.nil? end
to_hash()
click to toggle source
# File lib/dgrid/api/entity.rb, line 50 def to_hash { :description => description } end
type()
click to toggle source
# File lib/dgrid/api/entity.rb, line 25 def type self.class.type end