Module: Togglapper::Params
- Included in:
- ClientModule
- Defined in:
- lib/togglapper/params.rb
Instance Method Summary collapse
- #project(id: nil, name: nil) ⇒ Object
- #projects ⇒ Object
- #tag(id: nil, name: nil) ⇒ Object
- #tags ⇒ Object
- #user ⇒ Object
- #workspace(id: nil, name: nil) ⇒ Object
- #workspaces ⇒ Object
Instance Method Details
#project(id: nil, name: nil) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/togglapper/params.rb', line 26 def project(id: nil, name: nil) if id projects.find{ |project| project["id"] == id } elsif name projects.find{ |project| project["name"] == name } else projects.first end end |
#projects ⇒ Object
22 23 24 |
# File 'lib/togglapper/params.rb', line 22 def projects @projects ||= client.gc.my_projects end |
#tag(id: nil, name: nil) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/togglapper/params.rb', line 40 def tag(id: nil, name: nil) if id .find{ |tag| tag["id"] == id } elsif name .find{ |tag| tag["name"] == name } else .first end end |
#tags ⇒ Object
36 37 38 |
# File 'lib/togglapper/params.rb', line 36 def @tags ||= client.gc. end |
#user ⇒ Object
4 5 6 |
# File 'lib/togglapper/params.rb', line 4 def user @user ||= client.me end |
#workspace(id: nil, name: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/togglapper/params.rb', line 12 def workspace(id: nil, name: nil) if id workspaces.find{ |work| work["id"] == id } elsif name workspaces.find{ |work| work["name"] == name } else workspaces.first end end |
#workspaces ⇒ Object
8 9 10 |
# File 'lib/togglapper/params.rb', line 8 def workspaces @workspaces ||= client.gc.my_workspaces(user) end |