Class: XPlanner::Project

Inherits:
ModelHelper show all
Extended by:
AttrAccessorWithDirtyBit
Defined in:
lib/models/project.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AttrAccessorWithDirtyBit

dirty_accessor

Methods inherited from ModelHelper

base_url, base_url=, check_client_initialised, #check_client_initialised, #create_payload, fetch_from_remote, #hashify, parse_date, remote_delete, #remote_update, soap_client, soap_client=

Constructor Details

#initialize(p) ⇒ Project

Returns a new instance of Project.



10
11
12
13
14
15
16
17
# File 'lib/models/project.rb', line 10

def initialize( p )
  @dirty_bit = false

  @id                = p[:id]
  @name              = p[:name]
  @last_update_time  = Project.parse_date p[:last_update_time]
  @description       = p[:description]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/models/project.rb', line 7

def id
  @id
end

#last_update_timeObject (readonly)

Returns the value of attribute last_update_time.



7
8
9
# File 'lib/models/project.rb', line 7

def last_update_time
  @last_update_time
end

Class Method Details

.allObject



19
20
21
22
23
# File 'lib/models/project.rb', line 19

def self.all
  rpc = :get_projects
  path = [:get_projects_response, :get_projects_return, :get_projects_return]
  fetch_from_remote( rpc, {}, path, Project )
end

.create(name, description) ⇒ Object



32
33
34
35
36
37
# File 'lib/models/project.rb', line 32

def self.create( name, description )
  rpc = :add_project
  payload = { :projectData => { :name => name, :description => description } }
    path = [:add_project_response, :add_project_return]
  fetch_from_remote( rpc, payload, path, Project )
end

.delete(id) ⇒ Object



39
40
41
42
43
# File 'lib/models/project.rb', line 39

def self.delete( id )
  rpc = :remove_project
  payload = { :id => id }
    remote_delete( rpc, payload )
end

.retrieve(id) ⇒ Object



25
26
27
28
29
30
# File 'lib/models/project.rb', line 25

def self.retrieve( id )
  rpc = :get_project
  payload = { :id => id }
  path = [:get_project_response, :get_project_return]
    fetch_from_remote( rpc, payload, path, Project )
end

Instance Method Details

#deleteObject



45
46
47
# File 'lib/models/project.rb', line 45

def delete
  Project.delete @id
end


55
56
57
# File 'lib/models/project.rb', line 55

def link
    link_to_this_project = @@base_url + "do/view/project?oid=#{@id}"
end

#saveObject



49
50
51
52
53
# File 'lib/models/project.rb', line 49

def save
  rpc = :update
  payload = { :projectData => create_payload }
    remote_update( rpc, payload )
end