Module: Trajectory::DataStore

Extended by:
DataStore
Included in:
DataStore
Defined in:
lib/trajectory/data_access/data_store.rb

Instance Method Summary collapse

Instance Method Details

#find_iteration_of_project_with_id(project, iteration_id) ⇒ Iteration, false

Fetches a iteration of a given project by id

Parameters:

  • project (Project)

    the project

  • iteration_id (Integer)

    the iteration id

Returns:

  • (Iteration, false)

    the found iteration or false



75
76
77
# File 'lib/trajectory/data_access/data_store.rb', line 75

def find_iteration_of_project_with_id(project, iteration_id)
  project.find_iteration_by_id(iteration_id)
end

#find_project_by_id(id) ⇒ Project, false

Fetches a project by id in the collection of accessible projects

Parameters:

  • id (Integer)

    the project id

Returns:

  • (Project, false)

    the found project or false



49
50
51
# File 'lib/trajectory/data_access/data_store.rb', line 49

def find_project_by_id(id)
  projects.find_by_id(id)
end

#find_user_of_project_with_id(project, user_id) ⇒ User, false

Fetches a user of a given project by id

Parameters:

  • project (Project)

    the project

  • user_id (Integer)

    the user id

Returns:

  • (User, false)

    the found user or false



58
59
60
# File 'lib/trajectory/data_access/data_store.rb', line 58

def find_user_of_project_with_id(project, user_id)
  project.find_user_by_id(user_id)
end

#ideas_for_project(project) ⇒ Ideas

Fetches all ideas of a given project

Parameters:

  • project (Project)

    the project

Returns:

  • (Ideas)

    the collection of ideas



27
28
29
# File 'lib/trajectory/data_access/data_store.rb', line 27

def ideas_for_project(project)
  Ideas.from_json project, Api.ideas_for_project(project)
end

#iterations_for_project(project) ⇒ Iterations

Fetches all iterations of a given project

Parameters:

  • project (Project)

    the project

Returns:



66
67
68
# File 'lib/trajectory/data_access/data_store.rb', line 66

def iterations_for_project(project)
  Iterations.from_json project, Api.iterations_for_project(project)
end

#projectsProjects

Returns the collection of projects of the trajectory account.

Returns:

  • (Projects)

    the collection of projects of the trajectory account



6
7
8
# File 'lib/trajectory/data_access/data_store.rb', line 6

def projects
  @projects ||= Projects.from_json(Api.projects)
end

#stories_for_project(project) ⇒ Stories

Fetches all stories of a given project

Parameters:

  • project (Project)

    the project

Returns:

  • (Stories)

    the collection of stories



19
20
21
# File 'lib/trajectory/data_access/data_store.rb', line 19

def stories_for_project(project)
  Stories.from_json project, Api.stories_for_project(project)
end

#updates_for_project(project, since = DateTime.now) ⇒ Ideas

Fetches all updates of a given project since a given date

Parameters:

  • project (Project)

    the project

  • since (DateTime) (defaults to: DateTime.now)

    a datetime

Returns:

  • (Ideas)

    the collection of updates



36
37
38
39
40
41
42
43
# File 'lib/trajectory/data_access/data_store.rb', line 36

def updates_for_project(project, since = DateTime.now)
  updates = Api.updates_for_project(project, since).symbolize_keys!

  stories = Stories.from_json(project, updates[:stories])
  iterations = Iterations.from_json(project, updates[:iterations])

  Update.new(stories, iterations)
end

#users_for_project(project) ⇒ Users

Returns the collection of users of the trajectory account.

Returns:

  • (Users)

    the collection of users of the trajectory account



11
12
13
# File 'lib/trajectory/data_access/data_store.rb', line 11

def users_for_project(project)
  Users.from_json Api.users_for_project(project)
end