Class: LiquidPlanner::Resources::Treeitem

Inherits:
WorkspaceResource show all
Defined in:
lib/liquidplanner/resources/treeitem.rb

Direct Known Subclasses

Client, Container, Leaf

Instance Method Summary collapse

Methods inherited from LiquidPlannerResource

#get_raw, #load

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class LiquidPlanner::LiquidPlannerResource

Instance Method Details

#activities(scope = :all) ⇒ Object



30
31
32
# File 'lib/liquidplanner/resources/treeitem.rb', line 30

def activities( scope=:all )
  Activity.find( scope, :params => luggage_params )
end

#attach_document(attached_file_path, options = {}) ⇒ Object



42
43
44
45
46
# File 'lib/liquidplanner/resources/treeitem.rb', line 42

def attach_document( attached_file_path, options={} )
  doc = Document.upload_document( workspace_id, id, attached_file_path, options )
  doc.prefix_options = luggage_params
  doc
end

#clientObject



20
21
22
# File 'lib/liquidplanner/resources/treeitem.rb', line 20

def client
  client_id && Client.find( :one, :from => "/api/workspaces/#{workspace_id}/clients/#{client_id}" )
end

#comments(scope = :all) ⇒ Object



34
35
36
# File 'lib/liquidplanner/resources/treeitem.rb', line 34

def comments( scope=:all )
  Comment.find( scope, :params => luggage_params )
end

#documents(scope = :all) ⇒ Object



38
39
40
# File 'lib/liquidplanner/resources/treeitem.rb', line 38

def documents( scope=:all )
  Document.find( scope, :params => luggage_params )
end

#estimates(scope = :all) ⇒ Object



52
53
54
# File 'lib/liquidplanner/resources/treeitem.rb', line 52

def estimates( scope=:all )
  Estimate.find( scope, :params => luggage_params )
end

#item_collectionObject

LiquidPlanner::Item => ‘items’



57
58
59
# File 'lib/liquidplanner/resources/treeitem.rb', line 57

def item_collection
  self.class.to_s.split('::').last.downcase.pluralize
end


48
49
50
# File 'lib/liquidplanner/resources/treeitem.rb', line 48

def links( scope=:all )
  Link.find( scope, :params => luggage_params )
end

#noteObject



24
25
26
27
28
# File 'lib/liquidplanner/resources/treeitem.rb', line 24

def note
  Note.find( :one, :from => "/api/workspaces/#{workspace_id}/#{item_collection}/#{id}/note" ).tap do |n|
    n.prefix_options = luggage_params
  end
end

#packageObject



12
13
14
# File 'lib/liquidplanner/resources/treeitem.rb', line 12

def package
  package_id && Package.find( :one, :from => "/api/workspaces/#{workspace_id}/packages/#{package_id}" )
end

#parentObject



8
9
10
# File 'lib/liquidplanner/resources/treeitem.rb', line 8

def parent
  parent_id && Treeitem.find( :one, :from => "/api/workspaces/#{workspace_id}/treeitems/#{parent_id}" )
end

#projectObject



16
17
18
# File 'lib/liquidplanner/resources/treeitem.rb', line 16

def project
  project_id && Project.find( :one, :from => "/api/workspaces/#{workspace_id}/projects/#{project_id}" )
end

#workspace_idObject



61
62
63
# File 'lib/liquidplanner/resources/treeitem.rb', line 61

def workspace_id
  prefix_options[:workspace_id]
end