Class: RoxClient::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/rox-client-ruby/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Project

Returns a new instance of Project.



7
8
9
# File 'lib/rox-client-ruby/project.rb', line 7

def initialize options = {}
  update options
end

Instance Attribute Details

#api_idObject

TODO: remove project name once API v0 is dead



5
6
7
# File 'lib/rox-client-ruby/project.rb', line 5

def api_id
  @api_id
end

#categoryObject

TODO: remove project name once API v0 is dead



5
6
7
# File 'lib/rox-client-ruby/project.rb', line 5

def category
  @category
end

#nameObject

TODO: remove project name once API v0 is dead



5
6
7
# File 'lib/rox-client-ruby/project.rb', line 5

def name
  @name
end

#tagsObject

TODO: remove project name once API v0 is dead



5
6
7
# File 'lib/rox-client-ruby/project.rb', line 5

def tags
  @tags
end

#ticketsObject

TODO: remove project name once API v0 is dead



5
6
7
# File 'lib/rox-client-ruby/project.rb', line 5

def tickets
  @tickets
end

#versionObject

TODO: remove project name once API v0 is dead



5
6
7
# File 'lib/rox-client-ruby/project.rb', line 5

def version
  @version
end

Instance Method Details

#update(options = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rox-client-ruby/project.rb', line 11

def update options = {}
  %w(name version api_id category).each do |k|
    instance_variable_set "@#{k}", options[k.to_sym] ? options[k.to_sym].to_s : nil if options.key? k.to_sym
  end
  @tags = wrap(options[:tags]).compact if options.key? :tags
  @tickets = wrap(options[:tickets]).compact if options.key? :tickets
end

#validate!Object

Raises:



19
20
21
22
23
# File 'lib/rox-client-ruby/project.rb', line 19

def validate!
  required = { "version" => @version, "API identifier" => @api_id }
  missing = required.inject([]){ |memo,(k,v)| v.to_s.strip.length <= 0 ? memo << k : memo }
  raise PayloadError.new("Missing project options: #{missing.join ', '}") if missing.any?
end